Kategorie
Kurs CSS

Kolejność elementów

W css możemy określić porządek wyświetlania elementów wzdłuż osi z.

Kolejność elementów ustalamy za pomocą z-index.

selektor { z-index: wartość; }

Element, któremu przyporządkujemy wyższy indeks przykryje ten z mniejszym.

.box1 { z-index: 1; position: absolute; background: green; width: 100px; height: 100px; }
.box2 { z-index: 2; position: absolute; background: aqua; width: 100px; height: 100px; top: 20px; left: 20px; }
.box3 { z-index: 3; position: absolute; background: blue; width: 100px; height: 100px; top: 40px; left: 40px; }

box1

box2

box3

Dodaj komentarz

Twój adres e-mail nie zostanie opublikowany. Wymagane pola są oznaczone *