Home > Web Front-end > HTML Tutorial > To solve the problems related to html and css, attach the code_html/css_WEB-ITnose

To solve the problems related to html and css, attach the code_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:55:30
Original
1044 people have browsed it

Question: This is a page layout. The current problem is that if I remove the height attribute in main, then after re-running, the blue background layout at the bottom of the page will disappear. What is the reason for this?
The code is as follows:











Reply to discussion (solution)











#main{width: 1300px;background-color: green;overflow:hidden;}
Add overflow:hidden here

#footer {
width: 1300px;
clear: both;
height: 180px;
background-color: #00F;
}
plus clear: both; clear float

Already given on the 3rd floor Correct answer

The float attribute will cause the element to remove the normal document flow, that is, the browser will treat this element as if it does not exist when drawing other elements.
Think about it, what would happen if the elements in main no longer exist, and main has no height? The footer will move up!

Then the browser draws additional float elements, so that the footer is obscured by these two elements!

In addition:
Absolute and fixed positioning methods will also cause elements to move out of the normal document flow

3? Not quite right?
??The float should be cleared at the end of main

#main:after{content: "";display: block;float: none !important;clear: both;height: 0;}
Copy after login

Why is it OK to add overflow:hidden; in main? I still don’t know the reason.

Any attribute that can trigger the DIV’s hasLayout to return to the layout flow can solve this problem, such as setting its display: inline-block;

Why does this happen? Question, can anyone tell me?

http://beyondweb.cn/article_detail.php?id=437

Got it, thank you 10th floor, slwsss points will be given to you

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template