![](/img/trans.png)
[英]How can I center the text but not the number label of an HTML ordered list
[英]ordered list number and label misaligned
我有这样的label
和input
的ol
<ol>
<li>
<label for="testing" style="display:inline-block;width:200px;">
<!-- Content Here -->
</label>
<input type="checkbox" id="testing" name="test" value="" />
</li>
</ol>
如果我在label
加上width
, 这就是我得到的结果
如您所见, label
的第一行(以第一个单词Donex
)与列表中的数字1不一致。 我希望标签的文本与列表编号在同一行开头。
将标签样式设置为vertical-align:top;
请尝试这个:
<ol>
<li ><label for="testing" style="width:200px;display:inline-block;vertical-align:top">Donec vitae sem et purus luctus venenatis. In hac habitasse platea dictumst. Vivamus posuere fermentum dapibus.</label> <input type="checkbox" name="testing" value="" /></li>
</ol>
在Fiddle上运行。 希望这将是您的预期输出。
html
<ol>
<li><label for="testing">Donec vitae sem et purus luctus venenatis. In hac habitasse platea dictumst. Vivamus posuere fermentum dapibus.</label> <input type="checkbox" name="testing" value="" /></li>
</ol>
为演示1添加了CSS
ol li label {
display:block;
width:200px;
}
为演示2添加了CSS
ol li label {
float:left;
width:200px;
}
希望这个帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.