html - 样式化的 Html 单选按钮不检查

标签 html css

当我点击单选按钮时,按钮没有被点击,其他按钮的点击状态没有改变。

CSS 在这里:

  input[type="radio"] 
    {
    display:none;
    }
input[type="radio"] + label
{
    height: 20px;
    display:block;
    padding: 0 0 0 0px;
    vertical-align:top;
}

input[type="radio"] + label::before {
    content: url("../../../Content/images/Icons/radiounchecked.png");
    width: 20px;
    height: 20px;
    padding-right: 3px;

}
input[type="radio"]:checked + label::before {
    content: url("../../../Content/images/Icons/radiochecked.png");

}

这里创建的是MVC 4元素和radio

@Html.RadioButtonFor(Function(m) m.Variations(j).SelectedVariationID, Model.Variations(j).Options(i).OptionID )

在此处生成的 HTML 代码:

<input checked="true" id="Variations_0__SelectedVariationID" name="Variations[0].SelectedVariationID" type="radio" value="77">
<label for="77">Siyah Çikolata   $0.00</label>

最佳答案

没有足够的信息来弄清楚你的问题是什么,但我知道的一件事是,在设置单选框/复选框的样式时,你不应该对框使用 :before ,因为单击操作不会在其上激活。尝试在您的标签中添加一个跨度,并将该跨度设置为单选框/复选框。

至少,以前是这样。最近不确定。

关于html - 样式化的 Html 单选按钮不检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23955914/

相关文章:

html - 导航栏中的中心文本

html - 为什么位置:absolute adds 4px to the height of the outer container and how to remove it?

jquery - Fancybox,Jquery Validate & position :absolute

html - 单击 anchor 时取消选中复选框(仅限 CSS)

javascript - 如何使一个 div 适合另一个?

javascript - 如何选择只有特定类的元素?

html - 无需使用 Bootstrap 即可响应表数据

javascript - 是否可以控制浏览器窗口滚动条的可见性?

css - 向下滚动页面时 div 没有更新其 100% 高度?

javascript - 1pg 上的下一个/上一个箭头。水平滑动网站?