1

我在对话框的下一行有一个文本输入字段和 2 个按钮。

如何在对话框中心排列输入字段并将按钮与输入字段的右侧边缘对齐?

我已经设法使用以下代码实现了我所追求的结果,但感觉必须有更好的方法,因为这也会使文本输入向右对齐:

<style>

.container
{
    border: 1px solid #ccc;
    text-align: right;
        width: 100%;
        padding-right: 20px;
}

</style>


<div class="container">

<p><input id="selContactLists" name="selContactLists" type="text" class="textbox" id="textbox" /></p>
<input name="" type="button" value="Button"/> 
<input name="" type="button" value="Button"/> 

4

3 回答 3

2

CSS:

.container {
    display: inline-block;
}

input.text {
    width: 150px;
    display: block;
}

.right {
    float: right;
}

HTML:

<div class="container" >
    <input type="text" class="text" />
    <span class="right">
        <input type="button" value="button" />
        <input type="button" value="button" />
    </span>
</div>

工作示例:http: //jsfiddle.net/GTTFY/

于 2012-08-08T11:42:38.360 回答
0
<style>

.test
{
    margin-left:auto;
    margin-right:auto;

}
.test td
{
    float:right;
}
</style>

<table class="test">
    <tr>
        <td colspan=2><input name="" type="text" class="textbox" id="textbox" /></td>
    </tr>
    <tr>
        <td><input name="" type="button" value="Button"/> </td>
        <td><input name="" type="button" value="Button"/> </td>
    </tr>
</table>
于 2012-08-08T11:10:07.040 回答
0
<style>

.container
{
    margin-left:auto;
    margin-right:auto;
    width:150px;
    }

</style>


<div class="container" >

<input name="" type="text" class="textbox" id="textbox" />
<input name="" type="button" style="float:right;" value="Button"/> 
<input name="" type="button" style="float:right;" value="Button"/> 

</div>
于 2012-08-08T10:46:12.370 回答