Regarding the problem of li:hover, how to clear the float? _html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:14:09
Original
1455 people have browsed it

My code is as follows. When the mouse moves up, a box is displayed around it, but the one behind it will move backward. How can I prevent the

  • from floating when the mouse moves up? I am a newbie, and the code is all written by myself based on the knowledge I have learned. If you have any suggestions on the code below, I hope you guys can correct me.

    My 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>
    Copy after login


    My 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;}
    Copy after login


    Reply Discussion (Solution)

    <!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>
    Copy after login


    Take a look at what I have modified. Is it the effect you want?

    Thank you very much Blue Swallow!

    Clear float:
    clear:both;
    clear:left;
    clear:right;

  • source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!