How to center an element that is wider than its parent element?
I currently have a div with a fixed width of 900px. I'd like to add a child iframe with a fixed width of 950px, and I'd like it to be perfectly aligned to the center. How can that be done? Thanks. .container { width:900px } iframe { margin-left:-25px; width:950px; } You can place the child at 50%, then use a negative margin that is half the width of the child: .parent { position: relative; overflow: hidden; } .child { position: absolute; left: 50%; top: 0; margin-left: -475px; } This way you only need to know the size of the child element. I found a way to do it with dynamical widths here: