时未从CSS类中获取样式以下代码不起作用,这可能是因为我在同一个div中使用了class
和id
。我知道他们应该工作。DIV在使用编号为
参考:Can I use DIV class and ID together in CSS?
.PB {
position: relative;
margin: 0 auto;
background-color: #000;
width: 201px;
height: 422px;
z-index: 1;
}
#pb1-1 {
position: absolute;
margin: 0px;
background-color: green;
width: 65px;
height: 98.5px;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
z-index: 2;
text-align: right;
font-size: 14px;
-webkit-text-stroke: 1px white;
}
#pb1-2 {
position: absolute;
margin: 0px;
background-color: yellow;
width: 65px;
height: 98.5px;
top: 0px;
right: 0px;
bottom: 0px;
left: 68px;
z-index: 2;
text-align: right;
font-size: 14px;
-webkit-text-stroke: 1px white;
}
#pb1-3 {
position: absolute;
margin: 0px;
background-color: red;
width: 65px;
height: 98.5px;
top: 0px;
right: 0px;
bottom: 0px;
left: 136px;
z-index: 2;
text-align: right;
font-size: 14px;
-webkit-text-stroke: 1px white;
}
.pu:hover {
font-size: 24px;
background-color: #999999;
}
<div class="PB">
<div id="pb1-1" class="pu">1 </div>
<div id="pb1-2" class="pu">2 </div>
<div id="pb1-3" class="pu">3 </div>
</div>
谁能告诉我什么,我做错了什么?
您的预期成果是什么? –
我不确定连字符是否合法。你尝试过pb11而不是pb1-1吗? – ItayB