css| Float | Tips In the last two months have done several web site art, doing the process of DIV+CSS standard development has a further understanding. There are two points to get the biggest, one is thoroughly understand the CSS box mode (box model), and then one is to fix the troubled me for a long time "closed floating element" problem:
In general, if a child element uses float (float), the parent element is always unable to know exactly where the child element ends, so the bottom border of the parent element always crosses the middle of the child element or even the top, looking uncomfortable.
At the earliest, I had to add a <br/> or <div></div> set its properties to "Clear:all" at the end of the child element, but that would result in a lot of useless empty tags. Even some Web sites need to modify the ASP code to automatically add these empty tags, can only be considered an unwise.
It turns out that when the parent tag is also set to float (float), it can be closed in the correct position. So it is easy to float the father, so many ASP code does not need to be changed, when you need to add a clear attribute of the empty tag, if you can not add from the template, and need to add from the ASP code, There is no need to change the ASP code, just to set the parent container floating, if you need to change the ASP, then the parent container to set the parent container floating, a layer of floating up, can always solve the problem. Although this can save a lot of things, but it is easy to cause the entire page is all floating elements,-_-!!! is only a medium strategy.
Later, when searching for something else on the internet, I stumbled upon someone saying that you can do this by adding the following two attributes to the parent container's CSS properties:
Overflow:auto;
_height:1%;
Try it, it really works, in this way, this should be the best solution to the problem at present: Do not need to do task modification of the page, and basically do not need to the parent container--even the parent container of the parent container to make any changes, only to the parent container to add two of indifferent attributes to be done.
Now I have been using these two properties to close the floating element, it is too convenient ~
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.