我能做什么:
HTML:
<div id="test">
HELLO!
<input type="text">
</div>
CSS:
#test {
color:#F00;
}
#test input[type=text] {
background-color:#000;
}
如果#test
没有ID
而是一个班级,我想做的是同样的事情:
<div class="test">
...
在这种情况下我该如何编写CSS?
答案 0 :(得分:3)
使用.
表示课程。
.test {
color: red;
}
答案 1 :(得分:2)
只需将#
替换为.
(句号):
.test {
color:#F00;
}
.test input[type=text] {
background-color:#000;
}