Philipp Eggert Philipp Eggert -4 years ago 84
CSS Question

Can you place two fixed divs next to each other?

Currently I am working on my online-portfolio. I need to create two divs that are fixed and do not scroll. They both need to be the height of the page. The content in the middle however needs to scroll. the two bars left and right need to stay fixed (see picture)

My current code for the left div is the following:

.content_left {
background-color: #000;
float: left;
height: 100vh;
width: 10%;
position: fixed;

Thank you very much for your help and support! I am greatful with any advice and open to all kinds of solutions.

divs labeld 1&2 are the divs I need to be fixed

Answer Source

The simplest method would be to apply left:0px; to the left div and right:0px; to the right div. Then you only have to set position:fixed; for both of them.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download