javascript - 由于模板中的 css,单选按钮被禁用
问题描述
由于 css 文件,我的单选按钮似乎被禁用。css 由模板提供。我怎么知道问题是由于 css 文件引起的,因为当我注释掉对 css 文件的引用时,我的按钮工作正常。但是我需要 css 文件来使我的网页看起来更好。我尝试注释掉单选按钮的 CSS 样式,但无济于事。
我附上了我的单选按钮的屏幕截图,关于我如何创建它的 jquery,以及模板提供的 css 代码。
for( answers in allQuestions[i].answer){ //loops through array and dynamically adds answer values to radio buttons
var radioBtn = $('<input type="radio" class="radios" name="btnAnswers" value="'+ allQuestions[i].answer[j] + '" /><label for ="secondbtn">'
+ allQuestions[i].answer[j] + '</label><br>');
radioBtn.appendTo('#radios');
j++
}
下面是与无线电输入相关的 css
input[type="checkbox"] + label,
input[type="radio"] + label {
text-decoration: none;
color: #777;
cursor: pointer;
display: inline-block;
font-size: 1em;
font-weight: 300;
padding-left: 2.55em;
padding-right: 0.75em;
position: relative;
}
input[type="checkbox"] + label:before,
input[type="radio"] + label:before {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
font-family: FontAwesome;
font-style: normal;
font-weight: normal;
text-transform: none !important;
}
input[type="checkbox"] + label:before,
input[type="radio"] + label:before {
background: #f8f8f8;
border-radius: 6px;
border: solid 1px #e5e5e5;
content: "";
display: inline-block;
height: 1.8em;
left: 0;
line-height: 1.725em;
position: absolute;
text-align: center;
top: 0;
width: 1.8em;
}
input[type="checkbox"]:checked + label:before,
input[type="radio"]:checked + label:before {
background: #666;
border-color: #666;
color: #ffffff;
content: "\f00c";
}
input[type="checkbox"]:focus + label:before,
input[type="radio"]:focus + label:before {
border-color: #e89980;
box-shadow: 0 0 0 1px #e89980;
}
input[type="checkbox"] + label:before {
border-radius: 6px;
}
input[type="radio"] + label:before {
border-radius: 100%;
}
任何帮助表示赞赏,谢谢。
解决方案
您没有id
在输入元素上使用,因为应该for
在.label
input
id
推荐阅读
- android - 以编程方式从自定义视图创建多个视图
- dialogflow-es - Can I set the intent/context for the next DialogFlow interaction (for push notifications)?
- c# - 将 Datatable 转换为通用 IEnumerable
- mysql - 在 Docker 卷上挂载 /var/lib/mysql 时,驼峰式表不存在
- android - 在后台运行 CountDownTimer
- php - PHP Google Sheets API v4 从前一行获取所有格式(条件、日期等)并应用于新行插入的最有效方法?
- google-chrome - Chrome DevTools 不再看到远程设备
- ios - UIControlSegment 背景颜色在 iOS13 上不再透明
- python - Pandas 到 pyspark cumprod 函数
- c# - 如何将所有 404 URL 路由到 ASP .NET 中的视图或页面