首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >对齐HTML控件不会发生,尽管有相同的左点...?

对齐HTML控件不会发生,尽管有相同的左点...?
EN

Stack Overflow用户
提问于 2011-03-05 04:48:32
回答 1查看 481关注 0票数 0

这两个控件如何在不添加更多div的情况下对齐?我将它们都设置在左边:140px,但它们仍然不对齐。

代码语言:javascript
代码运行次数:0
运行
复制
<pre>
<span id="l4" disabled="disabled" style="display:inline-block;font-family:Arial;font-size:9pt;font-weight:bold;width:117px;">date</span><input 
name="date?4" type="text" value="1/1/2011 12:00:00 AM" id="date?4" runat="server" style="border-color:Black;font-family:Arial;width:300px;left: 140px" />

</br></br>

<span style="font-family: Arial; left: 140px;position: relative;"><input id="chkAll?5" type="checkbox" name="chkAll?5"/>
<label for="chkAll?5">Select All</label></span>
<div id="divChkLst?5" 
style="left:140px;width:300px;height:125px;position:relative;display:block;border-style:solid;border-width:thin;margin:0;border-color:Black;padding:0;

overflow:auto;">
        <table id="pMultiValueList?5" border="0" style="font-family: Arial;">
        <tr>
            <td><span pTag="ReportParameter5"><input id="pMultiValueList?5_0" type="checkbox" name="pMultiValueList?5$0" checked="checked" 

/><label for="pMultiValueList?5_0">qw</label></span></td>
        </tr><tr>
            <td><span pTag="ReportParameter5"><input id="pMultiValueList?5_1" type="checkbox" name="pMultiValueList?5$1" checked="checked" 

/><label for="pMultiValueList?5_1">as</label></span></td>
        </tr><tr>
            <td><span pTag="ReportParameter5"><input id="pMultiValueList?5_2" type="checkbox" name="pMultiValueList?5$2" checked="checked" 

/><label for="pMultiValueList?5_2">zx</label></span></td>
        </tr><tr>
            <td><span pTag="ReportParameter5"><input id="pMultiValueList?5_3" type="checkbox" name="pMultiValueList?5$3" /><label 

for="pMultiValueList?5_3">er</label></span></td>
        </tr>
    </table>
    </div>
</div></br></br>
</pre>
EN

回答 1

Stack Overflow用户

发布于 2011-03-05 04:50:59

不能在相对定位的元素上设置left属性。(嗯,你可以,但它不会有任何效果。)一种选择是设置

代码语言:javascript
代码运行次数:0
运行
复制
 position:absolute;

但您必须实际绝对地定位它们,并设置顶部/底部的值。

编辑:

正如下面在注释中提到的,您可以适当地偏移左值,如果您将它们都放在140px,并且它们一开始没有对齐,它们仍然会以相同的像素数偏移。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5199101

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档