CSS horizontal and vertical centering. Variant 3
An element is CSS centered, horizontally and vertically, when it has position: absolute.
HTML code:
<div class="example">
<div></div>
</div>
CSS code:
.example div {position: absolute; left: 0; top: 0; right: 0; bottom: 0; margin: auto;}
Browser support
- Windows
- Internet Explorer 8.0+
- Firefox 1.0+
- Google Chrome
- Opera 7.0+
- Safari 3.1+
- SeaMonkey 1.0+
- Mozilla 0.6+
- Netscape 6.0+
- Linux
- Firefox 1.0+
- Google Chrome / Chromium
- Opera 7.0+
- SeaMonkey 1.0+
- Mozilla 0.6+
- Netscape 6.0+
- NetSurf 3.0+