Centering DIV fluid with maximum width and absolute positioning

Before someone casts my vote, I posed another centering problem. Please read my situation before judging!

I am familiar with the most common methods of centering the material, but here is my situation. I have a DIV that should be both vertically and horizontally centered inside its parent, but it should also be fluid and not exceed a width of 890 pixels.

The maximum width reaches the required fluid, but since absolute positioned elements require a width rather than a maximum width, my vertical / horizontal centering breaks. Right now I have to sacrifice fluid over centering (or vice versa), but I'm NEED .

I would like to constantly keep the content in my DIV center, my current code does not do this, it hides the content when the window becomes smaller http://jsfiddle.net/cCQ2w/

Can anyone suggest a solution that might work for me?

+5
source share
2 answers

I tried to solve your problem. See this page: http://jsfiddle.net/PGce2/ . Thus, it is centered horizontally and vertically, and it is “liquid” and does not exceed a width of 890 pixels.

+2
source

You can provide a width of 100% with a maximum width set to 890px.

I showed [here] [1] a div pattern with horizontal and vertical center alignment.

[1]: http://jsfiddle.net/r2qL5sgj/1/
+2

All Articles