i just started to code html and css. I created a to make a navigation bar on top of my landing page but the problem is, the size of navbar doesnt fit into page when i zoom out, its getting smaller everytime i zoom out. How can i make it fit with keep everthing in body section centered?I zoomed out to %75 in the picture
Here is my code for HTML and CSS
* {
box-sizing: border-box;
}
body, html {
padding: 0px;
max-width: 1920px;
margin: auto;
}
.navigation-bar {
height: 70px;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, .2);
display: flex;
align-items: center;
}
<div class="navigation-bar">
<div class="logo">Gezy</div>
<div class="button-container">
<div class="join-now"><button>Join Now</button></div>
<div class="log-in"><button>Log In</button></div>
</div>
</div>
2
Answers
The
<body>
element is constraining it, because you’ve set a maximum width:Remove that and the constraint goes away.
To make sure your navigation bar remains fixed in size even when zooming out and everything in the body is centered, you can use a combination of relative and absolute positioning. Here’s an updated version of your code:
justify-content: space-between; in .navigation-bar to push the logo to the left and the buttons to the right.