如何仅使用CSS强制<div>与复选框内联?

时间:2017-02-14 19:43:17

标签: html css inline

我有这个,我不允许触摸HTML。

<div id="dynamic001" class="div-container">
    <input type="checkbox" class="checkbox" name="dynamic002" id="dynamic003">
    <label for="dynamic003" class="label1">
    <div class="div-text" id="dynamic004">
	Sample Text
    </div>	
</div>

有没有办法强制示例文字使用复选框内联,只使用CSS?

1 个答案:

答案 0 :(得分:2)

只需将内嵌块添加到div

即可
  .div-text {
    display: inline-block
  }

&#13;
&#13;
.div-text {
  display: inline-block
}
&#13;
<div id="dynamic001" class="div-container">
    <input type="checkbox" class="checkbox" name="dynamic002" id="dynamic003">
    <label for="dynamic003" class="label1">
    <div class="div-text" id="dynamic004">
	Sample Text
    </div>	
</div>
&#13;
&#13;
&#13;