* {
margin: 0 auto;
padding: 0;
box-sizing: border-box;
}
#header {
width: 100vw;
height: 50px;
background-color: grey;
display: flex;
justify-content: space-between;
align-items: center;
}
#left,
#right {
background-color: red;
width: 40px;
height: 100%;
text-align: center;
}
<div id="header">
<span id="left"></span>
<span id="topic">Lorem Ipsum Dolor</span>
<span id="right"></span>
</div>
2
Answers
Try setting all the default margins explicitly to 0. The margin of the body might be affecting your layout.