Home >Web Front-end >HTML Tutorial >The problem of element drift during css layout_html/css_WEB-ITnose

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

WBOY
WBOYOriginal
2016-06-24 12:06:191915browse

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

    Statement:
    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
    Previous article:Chapter 2 unit 1 of Bootstrap-Bootstrap CSS_html/css_WEB-ITnoseNext article:Chapter 2 unit 1 of Bootstrap-Bootstrap CSS_html/css_WEB-ITnose

    Related articles

    See more