【发布时间】:2014-02-26 21:57:23
【问题描述】:
我想为这个元素设置样式:
<input class="myslider" type="range" value="20">
这是有效的:
input[class*="myslider"] {
-webkit-appearance: none;
width: 100px;
background-color: black;
height: 2px;
}
但这不起作用:
.myslider input[type=range] {
-webkit-appearance: none;
width: 100px;
background-color: black;
height: 2px;
}
为什么我不能应用类选择器和属性选择器?
【问题讨论】:
-
因为您在 .myslider 中选择了一个输入
-
.myslider input[type=range]- 这意味着myslider是输入的父级。在这种情况下不是这样。 -
谢谢。这是否意味着直接父母,或者它可能是任何祖先?
-
输入 可以 嵌套在其他元素中,
.myslider input {}仍然可以工作 - 只要没有更具体的选择器覆盖它。
标签: css