div+css 的一个小问题,菜鸟向大家征求方法
我的css里有这样一个样式:
<style>
.img{margin-left:auto; margin-right:auto; width:800px; FLOAT: center;}
</style>
在body里有:
<body>
<div class= "img " style= " background-color:blue; ">
<img src= "Image/top11.jpg " width= "800 " height= "100 " alt= " " border= "0 ">
</div>
</body>
我碰到的问题是这样,我在div里插入图片后,不管图片hight,width设成多大。图片底部的div蓝色背景始终存在。请问我的css里还须怎样设置参数,才能实现填满蓝色背景不会多余出来?
我试过一种方法,在 div 里添加个表格就可以实现但我想在纯div下实现效果
------解决方案-------------------- <!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>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 无标题文档 </title>
<style>
.img{
margin-left:0px;
margin-right:0px;
width:800px;
margin-bottom:0px;
background-color:#FFFFFF;
border: 0px;
margin-top: 0px;
}
</style>
</head>
<body>
<div class= "img " style= " background-color:blue; "> <span class= "img " style= " background-color:blue; "> <img src= "Image/3567078.jpg " width= "100% " height= "100 " alt= " " border= "0 " /> </span> </div>
</body>
</html>
这样好像没有