标签中间的单选按钮显示

时间:2016-04-06 07:47:13

标签: html css

此html需要在标签左侧显示收音机图标,但它位于标签上方 Chrome(左图),firefox 45.0.1(右图)

enter image description here

我嵌套标签中的输入的原因是因为代码需要使标签可以点击"单击标签也会激活单选按钮"

如何让它在所有浏览器中正确显示?感谢

.radio-label {
    float: left;
}
<label class="radio-label">
      <input type="radio" name={{group}} checked={{value}} value={{name}}>{{caption}}
    </label>

4 个答案:

答案 0 :(得分:0)

display:inline-block属性并不意味着你强迫元素出现在左边它只是意味着你想要单行元素。使用float left实际意味着左对齐元素

.radio-inline {
    float: left;
}

答案 1 :(得分:0)

你只是试着,

.radio-inline {
 float: left;
}

答案 2 :(得分:0)

我认为你必须将两个包装在一个div中,然后将一个项目左对齐,另一个项目在右边,即单选按钮向左,标签向右。 给外部div一个特定的宽度,给每个项目50%

答案 3 :(得分:0)

你可以试试这个:

<label class="radio-label">
  <input type="radio" name={{group}} checked={{value}} value={{name}}>
  <div>{{caption}}</div>
</label>

和这样的造型......

.radio-label {
    width: 200px; // you can modify this as per your needs...
}
.radio-label, .radio-label input {
    float: left;
}

.radio-label div {
    overflow: hidden;
}