如何在单选按钮中放置文本?

A. *_*iaz 0 css radio-button materialize

我试图把一个单选按钮,里面的信件(Materialise的框架),这在像A和B的图像

我该怎么做呢?

Paw*_*mar 5

这是自定义单选按钮。

请参阅 css 中给出的注释。

input[type="radio"] {
  width: 30px;
  height: 30px;
  border-radius: 15px;
  border: 2px solid #1FBED6;
  background-color: white;
  -webkit-appearance: none; /*to disable the default appearance of radio button*/
  -moz-appearance: none;
}

input[type="radio"]:focus { /*no need, if you don't disable default appearance*/
  outline: none; /*to remove the square border on focus*/
}

input[type="radio"]:checked { /*no need, if you don't disable default appearance*/
  background-color: #1FBED6;
}

input[type="radio"]:checked ~ span:first-of-type {
  color: white;
}

label span:first-of-type {
  position: relative;
  left: -27px;
  font-size: 15px;
  color: #1FBED6;
}

label span {
  position: relative;
  top: -12px;
}
Run Code Online (Sandbox Code Playgroud)
<label>
  <input type="radio" name="options"/>
  <span>A</span><span>Option A</span>
</label>
<br/>
<label>
  <input type="radio" name="options"/>
  <span>B</span><span>Option B</span>
</label>
<br/>
<label>
  <input type="radio" name="options"/>
  <span>C</span><span>Option C</span>
</label>
<br/>
<label>
  <input type="radio" name="options"/>
  <span>D</span><span>Option D</span>
</label>
Run Code Online (Sandbox Code Playgroud)