html - 在同一行中并排对齐文本字段和按钮

标签 html css jquery-mobile

我需要始终并排放置一个文本字段和一个按钮。逻辑是这样的 - 按钮将始终位于屏幕的右侧。文本字段应占据左侧的其余宽度...我用过的代码

<html>
<head>
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.css" />
    <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.js"></script>
</head>

<body>
    <div data-role="page">
        <div data-role="content">
        <div style="display:inline;">
            <input type="text" placeholder="Enter your user name"></input>
            <a href="#" data-role="button" data-inline="true" class="normalBtn" style="margin-top:0px">Check</a>
        </div>
        </div>
    </div>
</body>
</html>

此处演示 - http://jsfiddle.net/d7T4E/

最佳答案

我不确定,但你可以试试这个:

<html>
<head>
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.css" />
    <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.js"></script>
</head>

<body>
    <div data-role="page">
        <div data-role="content">
        <div style="display:inline;">
            <input type="text" style="width:50% !important; float:left;" placeholder="Enter your user name"></input><a href="#" data-role="button" data-inline="true" class="normalBtn" style="margin-top:0px; float:left;">Check</a>
        </div>
        </div>
    </div>
</body>
</html>

关于html - 在同一行中并排对齐文本字段和按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8112875/

相关文章:

javascript - jQuery.live() 处理程序多次触发

html - Flexbox 图像布局

javascript - React Native Flatlist 不会动态呈现元素的宽度

html - 为什么没有显示 CSS 文件?

javascript - jquery mobile - 附加 html 内容并应用 JQuery mobile 的样式

javascript - 字符串比较返回 false。 jQuery Mobile 的奇怪 JavaScript 行为

javascript - 没有 jQuery 的分页。如何选择具有相同类别的一系列元素?我的逻辑有道理吗?

html - 在浏览器中删除链接引用

javascript - JQuery - 将 Google map 放在 "content"中不可见吗?

html - 如何将带有菜单的div放在图像旁边