日期:2014-05-17  浏览次数:20582 次

span中背景图去掉float属性就不显示?
初学css,遇到个奇怪的问题,把float去掉后就看不到背景图,firebug上也找不到span元素了,这是什么原因呢?
HTML code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>文本框中的事件应用</title>

    <style type="text/css">
            .spnInit{width:179px;height:40px;line-height:40px;float:right;background: url('Images/pic_Email_ok.gif') no-repeat;}
    </style>
</head>
<body>

           <span id="spnTip" class="spnInit"></span>
</body>
</html>




------解决方案--------------------
浮动设置以后、你那个span会自动变成块元素的
而你又设置了span的宽跟高、
所以背景图能看到