I need to place a div
(with position:absolute;
) element in the center of my window. But I am having problems doing so, because the width is unknown.
I tried this. But it needs to be adjusted as the width is responsive.
.center {
left: 50%;
bottom:5px;
}
Any ideas?
Heres a useful jQuery plugin to do this. Found here. I don't think it's possible purely with CSS
HTML:
CSS:
This and more examples here
I have used similar solution:
Where "X" is half of the width of a div I want to display. Works fine for me in all browsers.
Searching for an solution I got answers above and could make content centered with Matthias Weiler answer but using text-align.
Worked with chrome and Firefox.
Works on any random unknown width of the absolute positioned element you want to have in the centre of your container element.
Demo
This worked for me :