作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想使用 IE 11 通过 css 将复选框添加到多选。我使用的 css 适用于 Edge 等,但不适用于 IE 11。
CSS 和代码:
<style>
option:before
{
content: "☐ "
}
option:checked:before
{
content: "☑ "
}
<select class="ddlRole" id="ddlRole" style="width: 810px;" size="6" multiple="">
<option value="1">Administrator</option>
<option selected="selected" value="2">Manager</option>
<option value="3">User</option>
<option selected="selected" value="4">Sub Manager</option>
<option value="8">new role test 5</option>
</select>
或者,我将使用一个包含 2 列的表格,第一列是复选框列,接下来是选项的文本/名称。甚至可能是扩展的 Ul 和 Li?,虽然我真的不愿意。
谢谢
最佳答案
如果您尝试使用 HTML、CSS 和 JS,那么下面的示例可以在包括 IE 在内的所有主流浏览器上运行。
var expanded = false;
function showCheckboxes() {
var checkboxes = document.getElementById("checkboxes");
if (!expanded) {
checkboxes.style.display = "block";
expanded = true;
} else {
checkboxes.style.display = "none";
expanded = false;
}
}
.multiselect {
width: 200px;
}
.selectBox {
position: relative;
}
.selectBox select {
width: 100%;
font-weight: bold;
}
.overSelect {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
#checkboxes {
display: none;
border: 1px #dadada solid;
}
#checkboxes label {
display: block;
}
#checkboxes label:hover {
background-color: #1e90ff;
}
<form>
<div class="multiselect">
<div class="selectBox" onclick="showCheckboxes()">
<select>
<option>Select an option</option>
</select>
<div class="overSelect"></div>
</div>
<div id="checkboxes">
<label for="one">
<input type="checkbox" id="one" />First checkbox</label>
<label for="two">
<input type="checkbox" id="two" />Second checkbox</label>
<label for="three">
<input type="checkbox" id="three" />Third checkbox</label>
</div>
</div>
</form>
IE 11 中的输出:
引用:
How to use Checkbox inside Select Option
如果你想要一个只使用 CSS 的解决方案,你也可以在上面的链接中找到它。
关于css - 如何在 IE 11 中为多选添加复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54870036/
我正在尝试用 Swift 编写这段 JavaScript 代码:k_combinations 到目前为止,我在 Swift 中有这个: import Foundation import Cocoa e
我是一名优秀的程序员,十分优秀!