I am trying to centre, just using css, a div element both vertically and horizontally.
All the examples I have seen makes use of hardcoded values like pixel values.
Should it be possible to centre a div element without using javascript and using just percentage values?
Here is my test: jsfiddle.net
This can actually be done with the use of the
:beforeselector (questionable browser compability, but it can be done).Check out this great article by Chris Coyier on the subject to learn all about it, he also supplies you with a jsfiddle link to try it out.