单选按钮一个接一个地出现

Radio button's appearing one over another

我的应用程序上有自定义单选按钮。我的问题是目前单选按钮单独显示正常。当我尝试将它们中的两个排成一行时......它们出现在彼此之上而不是彼此相邻。我不能改变我的HTML,只能弄乱CSS。任何帮助将不胜感激。我以为这是由于每个标签的宽度,但给它一个低宽度有相同的结果。

HTML:

<label class="radio">
  <input type="radio">
  <span class="custom"><span>One</span></span>
</label>

CSS:

* {
  box-sizing: border-box;
}

input[type="radio"] {
  display: none;
  cursor: pointer;
}

label {
  cursor: pointer;
}

.radio span.custom > span {
  margin-left: 22px;
}

.radio .custom {
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 3px;
  display: inline-block;
  height: 20px;
  left: 0;
  position: absolute;
  top: 0;
  width: 20px;
}

.radio input:checked + .custom:after {
  background-color: #0574ac;
  border-radius: 100%;
  border: 3px solid #fff;
  content: "";
  display: block;
  height: 12px;
  position: absolute;
  top: 0;
  width: 12px;
}

.radio input + .custom {
  border-radius: 100%;
}

.checkbox input:checked .custom {
  background-color: blue;
  border-color: blue;
}

JSFiddle Demo

如果你想单独定位每个人,请这样做:

给每个 span 一个 id 标签并在你的 css:

中使用它
#your_span_id{ position: absolute; left:0px; height:100px; }
#your_second_span{ position:absolute; left:35px; height:100px;}

现在您的单选按钮在同一行中彼此相邻:)

干杯

scriptmind.js

只是编辑标签 class 所以(只是例子):

label {
  cursor: pointer;
  display:inline-block;
  width: 50px;
  position:relative;
}