The elements are the right size, but they don't go away. One of the explanations for margin

Source: Internet
Author: User

Development sometimes always encounter such a problem, a line of four elements, the total width of four elements is clearly more than the total width of the parent element is smaller, but the last element inexplicably photographed the next line, how to find the reason is not found.

I found a solution, though I didn't know it was the only one, but it was an explanation.

For example, the width of four elements is 25%, the width of the parent element is 1283 pixels, then 1283 pixels 25% is 320.75 pixels, according to the browser less than 1 pixels according to 1 pixels, the width of each element is actually tried 321 pixels, so the last element will never be with other elements and shoot. The workaround is that when the parent element is a fixed pixel, the child element should also be a fixed pixel, and when the child element is set to a fixed element, the minimum width of the parent element should be set if the parent element is a percentage, so that no more inexplicable problems will occur on the style.

Speaking of a little rough, writing articles is not my strong points, can help everyone is good ~

The elements are the right size, but they don't go away. One of the explanations for margin

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.