Html 如何给选项标签字体权重:在Chrome中加粗?
我想以粗体显示Html 如何给选项标签字体权重:在Chrome中加粗?,html,css,google-chrome,Html,Css,Google Chrome,我想以粗体显示选择选项的文本,如下图所示。 该代码在除Chrome之外的所有浏览器中都运行良好。我怎样才能解决这个问题 <select style="font-weight:normal"> <option style="font-weight:bold">Bold text here</option> <option style="font-weight:bold">Bold text here</option> <
选择
选项
的文本,如下图所示。
该代码在除Chrome之外的所有浏览器中都运行良好。我怎样才能解决这个问题
<select style="font-weight:normal">
<option style="font-weight:bold">Bold text here</option>
<option style="font-weight:bold">Bold text here</option>
<option style="font-weight:bold">Bold text here</option>
<option style="font-weight:bold">Bold text here</option>
</select>
此处为粗体文本
此处为粗体文本
此处为粗体文本
此处为粗体文本
可以给我们更多关于您需要什么的信息吗 例如:如果您需要将所选选项设置为粗体,我使用了一种类似这样的方法,当您选择一个选项时,它将变为粗体: 小提琴: html:
<select>
<optgroup id='111' label="111" style="display:none"></optgroup>
<option value="111">111</option>
<optgroup id='222' label="222" style="display:none"></optgroup>
<option value="222">222</option>
</select>
但是如果你想显示一个特殊的选项,即使它没有被选中。。。我帮不了你。。。(但答案问我)基本思想是这样的
<div id="list1" class="dropdown-check-list">
<span class="anchor">Select Fruits</span>
<ul class="items">
<li><b>Apple</b></li>
<li>Orange</li>
<li>Grapes </li>
<li>Berry </li>
<li>Mango </li>
<li>Banana </li>
</ul>
</div>
剧本
<script type="text/javascript">
var checkList = document.getElementById('list1');
checkList.getElementsByClassName('anchor')[0].onclick = function (evt) {
if (checkList.classList.contains('visible'))
checkList.classList.remove('visible');
else
checkList.classList.add('visible');
}
</script>
var checkList=document.getElementById('list1');
checkList.getElementsByCassName('anchor')[0]。onclick=function(evt){
if(checkList.classList.contains('visible'))
清单.类列表.删除('可见');
其他的
检查表。类列表。添加(“可见”);
}
这会让你开始。这使用了最少的javascript。你可以做得更多。
摆弄和试验。你的大部分可能不能,至少不能与本地
一起。它们的风格是出了名的难以设计,所以你要么不这样做,要么使用JavaScript替换查看可能的重复
.dropdown-check-list {
display: inline-block;
}
.dropdown-check-list .anchor {
position: relative;
cursor: pointer;
display: inline-block;
padding: 5px 50px 5px 10px;
border: 1px solid #ccc;
}
.dropdown-check-list .anchor:after {
position: absolute;
content: "";
border-left: 2px solid black;
border-top: 2px solid black;
padding: 5px;
right: 10px;
top: 20%;
-moz-transform: rotate(-135deg);
-ms-transform: rotate(-135deg);
-o-transform: rotate(-135deg);
-webkit-transform: rotate(-135deg);
transform: rotate(-135deg);
}
.dropdown-check-list .anchor:active:after {
right: 8px;
top: 21%;
}
.dropdown-check-list ul.items {
padding: 2px;
display: none;
margin: 0;
border: 1px solid #ccc;
border-top: none;
}
.dropdown-check-list ul.items li {
list-style: none;
}
.dropdown-check-list.visible .anchor {
color: #0094ff;
}
.dropdown-check-list.visible .items {
display: block;
}
<script type="text/javascript">
var checkList = document.getElementById('list1');
checkList.getElementsByClassName('anchor')[0].onclick = function (evt) {
if (checkList.classList.contains('visible'))
checkList.classList.remove('visible');
else
checkList.classList.add('visible');
}
</script>