I already set the border, padding and margin to 0px for the body and two of my divs. But I still can't seem to get rid of the gap.
#body{
padding: 0px ;
border:0px ;
margin:0px;
width:100%;
height:100vh;
}
#mainPage {
height:100vh;
width:100%;
background-color: #2469ff;
padding: 0px;
border:0px;
margin:0px;
}
#navBar{
height:70px;
width:100%;
Background-color: #1f1f1f;
padding: 0px ;
border:0px ;
margin:0px;
}
That's all my CSS so far.
Here is my HTML. It's very basic at the moment.
<html>
<head>
<title>
Ice Arena
</title>
</head>
<body>
<div id="mainPage">
<div id="navBar">
</div>
<div id="leftPanel">
</div>
</div>
</body>
</html>
As I said, I don't know why it's doing this. I'm sure I made a mistake, I'm still a beginner with CSS and HTML.
Use the following to remove the default margin from body
:
html,
body {
margin: 0;
}
Default CSS Values for HTML Elements
Default CSS Values for
body
[ display: block; margin: 8px;]
#body {
padding: 0px;
border: 0px;
margin: 0px;
width: 100%;
height: 100vh;
}
#mainPage {
height: 100vh;
width: 100%;
background-color: #2469ff;
padding: 0px;
border: 0px;
margin: 0px;
}
#navBar {
height: 70px;
width: 100%;
Background-color: #1f1f1f;
padding: 0px;
border: 0px;
margin: 0px;
}
html,
body {
margin: 0;
}
<html>
<head>
<title>
Ice Arena
</title>
</head>
<body>
<div id="mainPage">
<div id="navBar">
</div>
<div id="leftPanel">
</div>
</div>
</body>
</html>
Add the following CSS margin
reset:
html,
body {
margin: 0;
}
Snippet below:
html,
body {
margin: 0;
}
#body {
padding: 0px;
border: 0px;
margin: 0px;
width: 100%;
height: 100vh;
}
#mainPage {
height: 100vh;
width: 100%;
background-color: #2469ff;
padding: 0px;
border: 0px;
margin: 0px;
}
#navBar {
height: 70px;
width: 100%;
Background-color: #1f1f1f;
padding: 0px;
border: 0px;
margin: 0px;
}
<body>
<div id="mainPage">
<div id="navBar">
</div>
<div id="leftPanel">
</div>
</div>
</body>
Make the Div CSS parameter as below:
margin: 0 auto;
This will center your margin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With