css如何完全显示背景图片

<head>
<style type="text/css">
span{
float: left;
width: 100px;
height: 100px;


background: url(dropcap1.gif) 0 0 no-repeat;

}


</style>
</head>

<body>
<h2><span>A</span></h2>
</body>
</html>

注释:背景图片一般根据所填写的内容显示,当没有写文本或者写的文本大小小于背景图片的大小的时候,这时需要用float可以实现,注意宽和高的设置为图片本身的大小或者比图片本身应该大一些,这样才能完全显示。

posted @ 2014-11-07 10:13  amw863  阅读(321)  评论(0编辑  收藏  举报