繁体   English   中英

有序列表编号和标签未对齐

[英]ordered list number and label misaligned

我有这样的labelinputol

<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上运行。 希望这将是您的预期输出。

这是演示1还是演示2

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM