I have body set to width 100%, height 100% but when I add a header with 100% width and margin-left and margin-right the header is taking 100% width plus margin-left and margin-right value but I want to have margin-left and margin-right value included within 100% of the width of header without causing horizontal scrolling to the body how do I do it?
here is code :
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html,
body {
width: 100%;
height: 100%;
}
header {
width: 100%;
height: 70px;
margin-left: 30px;
margin-right: 30px;
border: 1px solid red;
}
<header></header>
Basically is this problem of box-sizing?? I'm using the next.js react framework. I want the total value of width calculated for a header that is 100% to include margin-left and margin-right value such that the header is in middle with margin-left and margin-right and not causing a horizontal scrollbar