我不明白为什么这不起作用,我有这种情况:
<div class="x" id="1">
<div class="x" id="2">
<div class="x" id="3">
</div>
</div>
</div>
这是css文件:
<style>
#1{display:block; width:300px; height:300px; background-color:blue}
#2{display:block; width:300px; height:300px; background-color:red}
#3{display:block; width:300px; height:300px; background-color:green}
</style>
为什么当我加载页面时,css规则不适用?我错过了什么吗? 谢谢
答案 0 :(得分:3)
ID不能以数字开头。请改用字母。
答案 1 :(得分:0)
id names cannot begin with numbers.
Although HTML5 appears to allow it,它在Firefox或Chrome中无效。
答案 2 :(得分:0)
两个人都是正确的。但是,我认为您需要在div中添加内容以查看规则是否适用。
答案 3 :(得分:0)
CSS standard表示id选择器不能以数字开头。