Ie6/7 margin-bottom failure Solution

Source: Internet
Author: User

Problem description:In ie6/7 browser, the floating element is close to the element of the last row of the parent element.(Single row refers to 1st rows)The margin-bottom value of is invalid!

Problem code:

<Style type = "text/css">

Ul {width: 250px; border: 1px # f00 solid; overflow: hidden;} ul li {float: left; width: 100px; height: 35px; border: 1px # 00f solid; margin-bottom: 10px ;}</style>

<Ul>

<Li> test margin-bottom </li> <li> test margin-bottom </li> </ul> <div> I am the following element </div> Trigger condition:The child element is set to float, and the margin-bottom value is added (the parent element has overflow: hidden to clear the float) Solution:  Method 1:(A floating element is added) The Code is as follows: 

<Style type = "text/css">

. Fix {clear: both; width: 0; height: 0; display: block; overflow: hidden ;}Ul {width: 250px; border: 1px # f00 solid; overflow: hidden;} ul li {float: left; width: 100px; height: 35px; border: 1px # 00f solid; margin-bottom: 10px ;}</style>

<Ul>

<Li> test margin-bottom </li> <li> test margin-bottom </li> <Li class = "fix"> </li></Ul> <div> I am the following element </div> Method 2: For ie6/7, add the padding-bottom attribute to the parent element. The value is equal to the value of margin-bottom of the child element. (We strongly recommend that you use this attribute !)  The Code is as follows:<Style type = "text/css"> ul {width: 250px; border: 1px # f00 solid; overflow: hidden; * Padding-bottom: 10px;} Ul li {float: left; width: 100px; height: 35px; border: 1px # 00f solid; margin-bottom: 10px;} </style>

<Ul>

<Li> test margin-bottom </li> <li> test margin-bottom </li> </ul> <div> I am the following element </div>, write memo!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.