How to force a checkbox and text on the same line?

前端 未结 6 398
长情又很酷
长情又很酷 2020-12-28 11:51

How can I force a checkbox and following text to appear on the same line? In the following HTML, I\'d only want the line to break between label and input, not between input

6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-28 12:37

    Another way to do this solely with css:

    input[type='checkbox'] {
      float: left;
      width: 20px;
    }
    input[type='checkbox'] + label {
      display: block;
      width: 30px;
    }
    

    Note that this forces each checkbox and its label onto a separate line, rather than only doing so only when there's overflow.

提交回复
热议问题