Pusat Mutlak (Vertikal & Horizontal) Gambar - Trik CSS

Anonim

Teknik gambar latar belakang CSS:

html ( width:100%; height:100%; background:url(7518965/absolute_center_vertical_horizontal_an_image_css-tricks.png.webp) center center no-repeat; )

Teknik Gambar Inline CSS +:

img ( position: absolute; top: 50%; left: 50%; width: 500px; height: 500px; margin-top: -250px; /* Half the height */ margin-left: -250px; /* Half the width */ )

Teknik tabel:

html, body, #wrapper ( height:100%; width: 100%; margin: 0; padding: 0; border: 0; ) #wrapper td ( vertical-align: middle; text-align: center; )