CSS图层(Layers)

CSS图层(Layers) 首页 / CSS入门教程 / CSS图层(Layers)

 CSS layers指的是将 z-index 属性应用于彼此重叠的元素。

z-index属性与 position 属性一起使用以创建图层效果。您可以指定哪个元素应该放在顶部,哪个元素应该放在底部。

<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> 

它将产生以下输出-

无涯教程网

链接:https://www.learnfk.comhttps://www.learnfk.com/css/css-layers.html

来源:LearnFk无涯教程网

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

教程推荐

手写 Python 虚拟机 -〔海纳〕

React Native 新架构实战课 -〔蒋宏伟〕

数据分析思维课 -〔郭炜〕

代码之丑 -〔郑晔〕

重学线性代数 -〔朱维刚〕

Web安全攻防实战 -〔王昊天〕

TensorFlow 2项目进阶实战 -〔彭靖田〕

性能测试实战30讲 -〔高楼〕

趣谈Linux操作系统 -〔刘超〕

好记忆不如烂笔头。留下您的足迹吧 :)