尽管有相同的LEFT点,但是没有发生HTML控件的对齐...?

时间:2011-03-04 20:48:32

标签: html alignment

这两个控件如何相互排列而不必添加任何div?我把它们都设置在左边:140px但它们仍然没有对齐。

<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>

1 个答案:

答案 0 :(得分:0)

您无法在相对定位的元素上设置left属性。 (嗯,你可以但它不会有任何影响。)一个选项是设置

 position:absolute;

但你必须绝对定位它们,并设置一个上/下值。

编辑:

如下面评论中所述,你可以适当地偏移左边的值,如果你把它们都放在140px并且它们没有开始对齐,它们仍将偏离相同的像素数。