html - CSS单选按钮标签需要圆圈

标签 html css

我有单选按钮,我试图在每个标签上显示圆圈

 <ul>
     <li>
         <input type='radio' value='1' name='radio' id='radio1'/>
         <label for='radio1'>Value 1</label>
     </li>
 </ul>

和这个的CSS

 ul {
     list-style: none;
 }
 li {
     display: inline-block;
     margin-right: 15px;
 }
 input {
     visibility:hidden;
 }
 label {
     cursor: pointer;
 }
 input:checked + label {
     background: red;
 }

我需要用圆圈显示每个单选按钮的标签 我从 Here 得到这个例子

最佳答案

您可以使用 border-radius 使标签成为一个圆圈。

ul {
    list-style: none;
}
li {
    display: inline-block;
    margin-right: 15px;
}
input {
    visibility:hidden;
}
label {
    cursor: pointer;
    display: inline-block;
    line-height: 50px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: red;
}
input:checked + label {
    color: white;
}
<ul>
    <li>
        <input type='radio' value='1' name='radio' id='radio1'/>
        <label for='radio1'>Value 1</label>
    </li>
    <li>
        <input type='radio' value='2' name='radio'  id='radio2'/>
        <label for='radio2'>Value 2</label>
    </li>
    <li>
        <input type='radio' value='3' name='radio'  id='radio3'/>
        <label for='radio3'>Value 3</label>
    </li>
</ul>

关于html - CSS单选按钮标签需要圆圈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35938247/

相关文章:

css - 用我自己的自定义 css 覆盖 Sharepoint 2010 css

html - 使用 Web 表单通过 HTTP POST 上传文件的最佳方式是什么?

html - img-circle 超出边距

android - PhoneGap cordova 创建卡住

javascript - 使 three.js 脚本固定在可滚动页面中

javascript - 在不改变选取框位置的情况下动态更改选取框文本

javascript - 有没有更好的方法来输入 "link"文本?

javascript - 如何使此下拉菜单在单击后处于事件状态?触摸后不

javascript - 如何添加 JavaScript 事件处理程序,以便在用户将鼠标光标移动到内容元素上时启动超时计时器?

Jquery css方法不设置CSS3变量