My webpage
My webpage minimized
As you can see in the pictures, when it’s full page it looks fine. but when I minimize the screen the buttons look off. How do i fix it? I want to keep my buttons from flying off here’s my entire code.
I tried using the meta viewport tag but it didn’t work.
body {
background-color: #F0EAD6;
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
.header {
display: flex;
align-items: center;
background-color: #00704A;
color: white;
height: 60px;
padding: 0 20px;
}
.logo {
width: 106px;
height: 64px;
margin-right: auto;
}
.button {
display: inline-block;
padding: 10px 20px;
border-radius: 20px;
margin-left: 10px;
background-color: white;
color: #00704A;
font-weight: bold;
text-decoration: none;
transition: background-color 0.19s ease, color 0.19s ease;
}
.button:hover {
background-color: #00704A;
color: white;
}
#headright {
margin-right: 55%;
}
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<header class="header">
<img class="logo" src="..WP projectCentral-Perk-Emblem.png" alt="Central Perk logo">
<div id="headright">
<a class="button" href="#">HOME</a>
<a class="button" href="#">MENU</a>
<a class="button" href="#">GIFT SHOP</a>
</div>
<div id="headleft">
<a class="button" href="#">Find a Store</a>
<a class="button" href="#">Sign In</a>
<a class="button" href="#">Join Now</a>
</div>
</header>
3
Answers
I made some changes with margins, widths, paddings, heights.
I think the problem was happening due to lack of space.
You need to give below to your headright and headleft because your container probably has some other
display
property due to which you cannot fit your buttons into thatThis should work.
nice design. So I think that your issue is probably in the fact that you are using percentages in the code. It’s not the best practice to use percentage values in the margin. I think that’s why the design keeps messing up. If you want to adjust the code to work for smaller screens you can always use media queries but never percentages. I made some adjustments to the code and also added a media query for smaller screens. You can check the code with the comments added. I’m using flex, specifically flex-end to push the buttons all the way to the end of the page(all the way to the right). I hope that helps.