Center left and right div together


Hi all,

Hope you can share your ideas on this one. How can I get the left and right div to be close to each other (e.g. 5 px in between) and get them to be centered horizontally as 1?

Same for the header actually, can't get it to center with margin:auto.

#header {

.left {

Thanks for your advise!


Can i see the rest of the code? I feel like there is something missing, there are a couple of ways: you could float both .left and .right left, this way they will be close beside each other. You could wrap your .left and .right in one div, and set this to a width of .left + .right (keep in mind the margin, padding and border. You could also use div { box-sizing: border-box } so padding and width are part of the width of your element.

you could centralize your #header by using margin: 0 auto; but because your #header is fixed, you also need to add left: 0; right: 0; I am not sure why that works yet, but i learned it does work

If you need more help, i need to see the rest of your code. Hopes this helped at least a bit