Reputation: 153
I'm trying to have the header go from one side of the screen to the other and stop just like how the left side does, however it extends much pass and goes off the screen. Also I thought that when you set a specific width that meas that it starts from the edge o the screen and stops at the other edge of the screen.
body{
background-color: white;
width: 100%;
}
header{
width: 100%;
background-color: #0000CD;
}
nav{
display: flex;
justify-content: center;
}
ul.main-menu{
display: flex;
width: 100%;
justify-content: space-around;
list-style: none;
}
li.menu-item{
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Why OneDrive?</title>
<link rel="stylesheet" href="../CSS/styles.css">
<script src="../JS/3picslideshow.js" type="text/javascript" charset="utf-8" async defer></script>
</head>
<body>
<header>
<nav>
<ul class="main-menu">
<li class="menu-item">Home</li>
<li class="menu-item">Usage</li>
<li class="menu-item">About</li>
<li class="menu-item">Acknowledgments</li>
</ul>
</nav>
</header>
</body>
</html>
Upvotes: 1
Views: 550
Reputation: 67748
The body
element has a margin by default. Remove that by adding
html, body {
margin: 0;
}
.. and a 100% wide element will perfectly fit the width. Example:
body {
margin: 0;
}
.x {
width: 100%;
background: #fa0;
}
<div class="x">The DIV with class "x"</div>
Upvotes: 1
Reputation: 459
Remove the width: 100%; from the body class. You don't need it. That will fix your issue.
Upvotes: 3
Reputation: 65
Try removing width: 100%
from your body
tag.
It seems to work.
Example here.
Upvotes: 0