代碼如下,當鼠標移動上去時,周圍顯示一個方框,但是后面的會向后移動,如何才能使得當鼠標移上去時后面的<li>不浮動?應該如何修改代碼呢?
HTML code
<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>
CSS代碼:
CSS code
.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;}
重新將代碼修改了下,就可以實現我所想要的效果了,如下詳細的代碼:
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>
<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>
新聞熱點
疑難解答