问题
Basically I got problem with the edge of my website, it got this white spaces :
http://sadpanda.us/images/1885204-15X1WA4.jpg
While I want that web to look like this :
http://sadpanda.us/images/1885205-VG8KJ23.jpg
no white spaces.
Any idea where I've done wrong?
回答1:
That looks very much like the default margin
on the <body>
.
body {
margin: 0;
}
Should solve it for you.
Quick Demo:
CSS:
html, body {
height: 100%;
}
div {
width: 100%;
height: 100%;
background: #ddd;
}
DEMO WITH SPACE
CSS:
html, body {
height: 100%;
}
body {
margin: 0; /* This will stop the margin, setting it to 0 */
}
div {
width: 100%;
height: 100%;
background: #ddd;
}
DEMO WITHOUT SPACE
回答2:
each browser has some style for elements like body,h1...etc,that is called as user agent style sheet, they have some margin, if you want reset all css just use universal tag and put margin:0 ... like below..
*{ margin: 0;}
来源:https://stackoverflow.com/questions/21705517/html-css-marginwhite-spaces-at-webpage-edges