Navbar Overflowing with the padding
Guys, I need some help with my CSS code.
I'm new ro CSS and have been trying to develop a website for a client. At first, as a designer, my job was to get it done in figma, but he decided to have me build it and learn html/css in the proccess.
I'm now doing the navbar, here is the code:
The problem I'm having is that inputing the lateral paddings is making the bar overflow to the right. What am I doing wrong?
2 Replies
by default, when you set a size to an element, it's done to the content-box of the element (not including padding or border), So if you include padding to the 100% width, it will make it wider than the screen. to prevent that, you can set: "box-sizing: border-box"
a common thing to do is to reset this for every element on the page, so you don't have to worry about it anymore
https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing
MDN Web Docs
box-sizing - CSS: Cascading Style Sheets | MDN
The box-sizing CSS property sets how the total width and height of an element is calculated.
Have you got it fixed?