Solution to double margin bug in IE browser

Source: Internet
Author: User

Original article address:

Http://www.positioniseverything.net/explorer/doubled-margin.html

Use the code to set a floating container floatbox to float on the left side of the main container box, and set the left side of the floatbox to margin-left to make it a distance from the left side of the box.

The Code is as follows::

. Floatbox {float: left;

Width: 150px;

Height: 150px;

Margin: 5px 0 5px 100px;

}

The last 100px is set to margin on the left. The code is perfect till now, but IE does not think this when it is opened in IE:

IE doubles the number of margin-left, which is the case above.

Note:: This bug occurs between the inner edge of the floating container (floatbox) and the main container (box) only when the margin of the floating container is consistent with its floating direction, all floating elements similar to margin afterwards will not be affected by this bug. Only the first one in a group of floating elements is affected by this bug. In addition, this floating bug is evenly distributed, as is the floating on the right.

Solution:

Add display: inline to the floating container as follows:

. Floatbox {float: left;

Width: 150px;

Height: 150px;

Margin: 5px 0 5px 100px;

Display: inline;

}

OK. Let's take a look ~

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.