CSS дает вам возможность создавать слои из различных элементов. Уровни CSS относятся к применению свойства z-index к элементам, которые перекрываются друг с другом.

Свойство z-index используется вместе со свойством position для создания эффекта слоев. Вы можете указать, какой элемент должен находиться сверху, а какой элемент должен быть внизу.

Свойство z-index может помочь вам создать более сложные макеты веб-страниц. Ниже приведен пример, показывающий, как создавать слои в CSS.

< html>
   < head>
   < /head>
   < body>
      < div style="background-color:red; width:300px; height:100px; position:relative; top:10px; left:80px; z-index:2">
      < /div>
     
      < div style="background-color:yellow; width:300px; height:100px; position:relative; top:-60px; left:35px; z-index:1;">
      < /div>
     
      < div style="background-color:green; width:300px; height:100px; position:relative; top:-220px; left:120px; z-index:3;">
      < /div>
   < /body>
< /html>

Это приведет к следующему результату -





Понравилась статья? Поделитесь ею с друзьями и напишите отзыв в комментариях!

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.

Ok