开发者

*curious behavoir* why is font-size over width/height

<html>

<head>
<style type="text/css">
 ul {font-size: 25px; list-style: none;}
 li{margin-left:0; padding: 0px 5px;}
 li a {width: 300px; height: 300px; height:300px; background:url(whatever) bottom left;}
 li a span{visibility: hidden;}
 </style>
</head>

&l开发者_开发百科t;body>
<ul><li>
<a href="#"><span>some txt</span></a>
</li></ul>
</body>

</html>

why is here the ul's font-size making the width/height and not the witdth/height of the a ?


@remy; a & span are inline element so it's not take the height , width , vertical margin & padding so give

a , span{
display:block
}


Because an anchor tag is inline by default. Try adding

li a {
  display: block;
}

to convert it to a block; this will mean you can assign it a width & height.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜