CSS 选择器优先级

标签 css css-selectors

为什么css选择器

select, textarea, input[type="text"], input[type="password"],input[type="datetime"], input[type="datetime-local"], input[type="date"], input[type="month"], input[type="time"], input[type="week"], input[type="number"], input[type="email"], input[type="url"], input[type="search"], input[type="tel"], input[type="color"], .uneditable-input

优先于

input.text-style

对于以下 html:

<input type="text" required="required" name="poemDataCollector[name]" id="poemDataCollector_name" class="text-style">

我读到类应该优先于 html 标签...

最佳答案

属性选择器同样特定于类选择器。

如果你想覆盖你可以这样写的类:

input.text-style[type="text"]

查看此决定了解更多 What is the specificity of the attribute selector?

阅读此 http://www.w3.org/TR/selectors/#specificity

关于CSS 选择器优先级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11427101/

相关文章:

css - 类的第一个元素的CSS选择器

html - 如何在没有内联样式的情况下为无序列表中的每个列表项设置样式?

css - 为什么 webkit 过滤器悬停时堆叠顺序会发生变化?

html - 如何将样式表渲染到页面 View

javascript - 有没有办法为在刷新或 DOM 位置发生变化时不会获得无效元素的元素生成唯一选择器?

javascript - 排除 div 内第一个 span 标签的子级

html - 了解 CSS 选择器优先级/特异性

html - Firefox 上带有固定 header 的 CSS 视差

php - 在 the_excerpt() 中插入一个链接;标签

Python BeautifulSoup - 查找类名称以某个字符串开头的所有元素