The problem of element drift during css layout_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:06:19
Original
1893 people have browsed it

I am a newbie. When I use CSS to position, some elements drift inexplicably, which makes me very painful. I would like to ask someone to give me some guidance. Here is a piece of code that I used to explain this problem. The red marked part is the problem. Focus, when I comment out the ul float, his parent element second will create a gap with first. Where does this gap come from, and what is its connection with this float. Furthermore, why does the ul element drift downward a little distance as a whole? Is there any way to properly solve this problem? This is just an example. I have encountered many similar problems. Obviously, the size is fine. The parent element is filled, but it is not satisfied and will drift downwards. Please give me some advice




Test




< ;div class="firstchild">



#">List
  • List

  • List

  • List

  • List






  • Reply to discussion (solution)

    Haha After every float you Must clear:both

    I solved it myself, because ul itself has a border, declare it as margin: 0px; padding: 0px; that’s it

    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 Recommendations
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template