2

I have the following css:

#leftmenu{
top: 400px;
left: 4%;
position: fixed;
width: 150px;
height: 200px;
background: transparent;
}

html,body{
height:100%;
margin:0;
}

"Leftmenu" has a fixed position in the left of the screen, but now top is defined in px (400) and I want to define it in %, and the div "leftmenu" must be vertically aligned centered. The height must be the same.

Thank you

maurice77
  • 79
  • 1
  • 2
  • 8

1 Answers1

6

Update your css to this:

#leftmenu{
  top: 50%;
  margin-top: -100px; // half height of this container
}
Morpheus
  • 8,829
  • 13
  • 51
  • 77