css vertically centering a fixed positioning div

The best solution I’ve seen for both vertically and horizontally centering a position: fixed div is:

position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);

Fiddle and source. You don’t need to know the dimensions of the div and it doesn’t require any container divs. The centered div‘s width can even be a percentage (which was what I was looking for when I found this solution).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)