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

Source: Internet
Author: User

Tags: size based on width pixels why can't method write article browser

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.

Tags Index: