日期:2014-05-17 浏览次数:20776 次
<div class="test"> <ul> <li><a href="http://xxx.com"><img src="images/test.jpg" width="218px" height="218px"></a><br/><a href="http://xxx.com">说明文字</a></li> <li><a href="http://xxx.com"><img src="images/test.jpg" width="218px" height="218px"></a><br/><a href="http://xxx.com">说明文字</a></li> <li><a href="http://xxx.com"><img src="images/test.jpg" width="218px" height="218px"></a><br/><a href="http://xxx.com">说明文字</a></li> <li><a href="http://xxx.com"><img src="images/test.jpg" width="218px" height="218px"></a><br/><a href="http://xxx.com">说明文字</a></li> </ul> </div>
.test{position:relative;display:block;border:1px solid #DADADA;width:958px;clear:both;height:520px;overflow:auto;zoom:1;} .test ul{list-style-type:none;width:auto;margin:0px;padding:0;clear: both;} .test ul li{display:block;float:left;width:220px;margin:5px 8px 5px 8px;height:240px;padding:1px;} .test ul li:hover{border:1px solid #DADADA;} .test ul li a{width:218px;text-decoration:none;} .test ul li a:hover{text-decoration:underline;}
<!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=utf-8" /> <title>无标题文档</title> <style type="text/css"> *{margin:0;padding:0;} .test{position:relative;display:block;border:1px solid #DADADA;width:auto;clear:both;height:520px; margin:20px;overflow:auto;zoom:1;} .test ul{list-style-type:none;width:auto;margin:0px;padding:0; clear:both;} .test ul li{display:inilne-block;float:left;margin:5px 8px 5px 8px;padding:1px;} .test ul li a{width:218px; height:218px;text-decoration:none; display:block;border:1px solid #DADADA; text-align:center;} .test ul li a:hover{text-decoration:underline; border:1px solid red;} .test ul li a img{border:0;} .test ul li p{text-align:center; margin-top:8px;} </style> </head> <body> <div class="test"> <ul> <li><a href="http://xxx.com"><img src="images/test.jpg" /></a><p href="http://xxx.com">说明文字</p></li> <li><a href="http://xxx.com"><img src="images/test.jpg" /></a><p href="http://xxx.com">说明文字</p></li> <li><a href="http://xxx.com"><img src="images/test.jpg" /></a><p href="http://xxx.com">说明文字</p></li> <li><a href="http://xxx.com"><img src="images/test.jpg" /></a><p href="http://xxx.com">说明文字</p></li> </ul> </div> </body> </html>
------解决方案--------------------
清除浮动:
clear:both;
clear:left;
clear:right;