Why does the div have a gap from the top of the page? _html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:21:24
Original
2778 people have browsed it

HTML CSS

As shown in the picture, there is a gap that cannot be removed. .


Just put a div




Then the following is the style
div.page {
background-color:#518845;
margin-left:auto;
margin-right:auto;
margin-top:0px ;
width:1000px;
height:200px;
overflow:hidden;
}

Even though margin-top:0px is set, why is there still a gap from the top of the page?

Reply to discussion (solution)

You set the body margin: 0; padding: 0;

Many tags have default settings in different browsers The margin and padding values, you can clear the default values ​​before use, and return them to 0, so this problem will not occur
Solution 1:
body,html,div{ padding:0; margin:0 ;}
Solution 2:
Directly *{padding:0; margin:0} or
Because there are too many tags and many are not used, so the first method is recommended, just write commonly used tags.

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