css - Center asymmetric div in browser -


i have main div (width: 960px) centered in browser window "margin: 0px auto". time time show ad (160x600, margin left side maybe 10px) attached right side of main div main div should remain in center of browser.

how can that?

you can place ad inside centred div, make centred div position:relative, ad position: absolute , set left appropriate: http://jsfiddle.net/3vqh8/1/

#center {     background: blue;     width: 960px;     height: 600px;     margin: 0 auto;     position: relative; }  #ad {     position: absolute;     height: 600px;     width: 160px;     background: red;     right: -170px; } 

Comments