Quantcast
Channel: bbird.me
Viewing all articles
Browse latest Browse all 10

How to center HTML element with absolute positioning

$
0
0

Believe it or not, something like this will do:

.element
{
left:0;
right:0;
position: absolute;
width: 100%; //would be nice, also
}

You can also center the content using text-align. Now as for width, some say that it is required, but in many cases I didn’t see any difference (I guess this is dependent on the browser). And you’re encouraged to add max-width combined with width:100% values.

Post How to center HTML element with absolute positioning je prvi puta viđen na bbird.me.


Viewing all articles
Browse latest Browse all 10

Trending Articles