我的元素包含以下代码,但没有得到#M、#D 等。我是 CSS 新手
<div id="DivM" class="M" style="display: none;">
</div>
<div id="DivB" class="B" style="display: none;">
</div>
<div id="DivD" class="D" style="display: none;">
</div>
<div id="DivL" class="L" style="display: none;">
</div>
<div id="DivO" class="O" style="display: none;">
</div>
和CSS
#M {background: url(/images/M.png) no-repeat;width: 148px;height:90px;top: 18px;left:3px;outline:none;list-style:none;}
#B {background: url(/images/B.png) no-repeat;width: 292px;height:90px;top: 0;left: 0;outline:none;list-style:none;}
#D {background: url(/images/D.png) no-repeat;width: 158px;height:90px;top:18px;left:78px;outline:none;}
#L {background: url(/images/L.png) no-repeat;width: 158px;height: 50px;top:82px;left:22px;outline:none;list-style:none;}
#O {background: url(/images/O.png) no-repeat;width: 158px;height:90px;top:37px;left:36px;outline:none;list-style:none;}
最佳答案
这些样式将不起作用,#M
以 id
为 M
的元素为目标,.M
以 M
的 class
为目标元素。这会起作用:
.M { ... }
.B { ... }
.D { ... }
.L { ... }
.O { ... }
或者这个:
#DivM { ... }
#DivB { ... }
#DivD { ... }
#DivL { ... }
#DivO { ... }
关于css - css中的#classname是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15785159/