0

I have a div width is 800px in the center aligned with:

  min-height:800px;
  margin-left:auto;
  margin-right:auto;

I have a div on the right of it which is fixed like:

  left:50%;
  padding-left:400px;
  position:fixed;

But now the div is over the main content.

So if there is a button in main content I can't click it because the fixed div is over it.

I have tried giving it a lower z-index, but if I do that I can't click the buttons on the side div.

Is it possible to give it a margin left:50% + 400px; so I don't need padding?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Sven van den Boogaart
  • 11,833
  • 21
  • 86
  • 169

1 Answers1

5

Just change padding-left to margin-left:

left: 50%;
margin-left: 400px;
position: fixed;

Or use calc in modern browsers:

left: calc(50% + 400px);
position: fixed;
Community
  • 1
  • 1
gilly3
  • 87,962
  • 25
  • 144
  • 176