html - 将 CSS 应用于 HTML 选择标签

标签 html css css-selectors

如何使用以下选择标签的名称或 ID 来对其应用 CSS?

<div class="span5">
  <select name="fields[abc][]" id="fields[abc]" style="width: 300px;" size="7" multiple="true">
    <option title="abc" value="abc">abc</option>
    <option title="Other" value="Other">Other</option>
  </select>
</div>

这不起作用:

select[name=fields[abc][]] {    
  background-color: yellow !important;;
  border: 1px solid #ccc;
  min-height: 550px;
}   

这是fiddle

最佳答案

将属性值括在双引号内:

select[name="fields[abc][]"] {
}

演示:

select[name="fields[abc][]"] {
  background-color: yellow !important;
  border: 1px solid #ccc;
  min-height: 550px;
}
<select name="fields[abc][]" id="fields[abc]" style="width: 300px;" size="7" multiple="multiple">
  <option title="abc" value="abc">abc</option>
  <option title="Other" value="Other">Other</option>
</select>

关于html - 将 CSS 应用于 HTML 选择标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28316005/

相关文章:

html - 用 :nth-child? 选择一半的元素

javascript - 带 Glyphicon 的按钮比带文本的按钮小

html - LinkedIn 共享按钮从 URL 中删除了 QueryString

css - 为什么 Safari 在每个 CSS 分页符后不断添加连续更大的边距?

html - 最小化网格 CSS 的问题

css - 是否有 CSS 父级选择器?

CSS nth-child(奇数): hover when hover:not used

html - 悬停在我的图像上时,我的导航在 IE9 中消失

javascript - 使用 Enter 触发 .click 函数

javascript - 如何在自定义弹出加载中加载js/css文件