div background color not setting all area

后端 未结 5 1528
我在风中等你
我在风中等你 2021-01-26 05:00

I have a div containing 3 div inside it. My problem is when am setting background color to first div, the div inside first div is not applying the background.

My code is

5条回答
  •  我在风中等你
    2021-01-26 05:15

    What about create a new class style:

    .clearfix{
       clear:both;
    }
    

    Then add it to the end of your HTML:

    Heading

    Description

    Heading

    Description

    Heading

    Description

    And don't use such a things like align="center" it's not a proper way of centering things due to HTML5 standards. All those things should be achieved by CSS, you shouln't write any styles in your HTML tags, that's a good practice.

    Hmmm, I also think that you don't need height:auto in your how_next style.

    Why clear:both?

    You must do this in your case, because you're using floating elements, which won't make your parent expand by them.

    Have a look! http://www.w3schools.com/cssref/pr_class_clear.asp

提交回复
热议问题