[英]Why is my block element's width and height 0?
I'm working on html for a 5-star rating system, and for some reason I can't get my anchors to take on a width and height, even when I set them as a block element. 我正在为五星级评级系统开发html,由于某些原因,即使将它们设置为块元素,我也无法使锚点具有一定的宽度和高度。 I've narrowed the problem down to this basic code:
我将问题缩小到以下基本代码:
CSS: CSS:
.outerdiv{
height:20px;
width:90px;
background-color:red;
}
.innerdiv{
height:20px;
width:63px;
background-color:blue;
}
.1{
display:block;
height:20px;
width:18px;
z-index:5;
background-color:green;
}
.1:hover{
background-color:orange;
}
HTML: HTML:
<div class="outerdiv">
<div class="innerdiv">
<a class="1"></a>
</div>
</div>
Also at: http://jsfiddle.net/knoell8504/qsjqL/4/ The main difference between this code and the code I'm using is that this code uses a background color where my code uses a background image. 另请参见 : http : //jsfiddle.net/knoell8504/qsjqL/4/此代码与我正在使用的代码之间的主要区别在于,此代码使用背景色,而我的代码使用背景图像。
Class names cannot start with a number (I think that's changing in HTML5, but it's still not a good idea). 类名不能以数字开头(我认为HTML5中这种情况正在改变,但这仍然不是一个好主意)。 Therefore the styles aren't being applied.
因此,没有应用样式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.