3d预测号码,家族企业论文,电子商务专业
z-index
属性,如:固定定位
、相对定位
、绝对定位
。z-index
属性值是0
。2
个定位的元素都没有设置z-index
属性,后者会覆盖到前者。2
个定位的元素都设置了z-index
属性,并且数值一样大还是后者会覆盖到前者。z-index
属性的属性值大的就会覆盖小,就是设置元素的层级。用实践证明这句话,如果2
个定位的元素都没有设置z-index
属性,后者会覆盖到前者。
代码块
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>z-index属性</title> <style> div{ width: 200px; height: 200px; } .div1{ background-color: red; position: relative; top: 50px; left: 50px; } .div2{ background-color: slateblue; position: relative; left: 100px; } </style> </head> <body> <div class="div1"></div> <div class="div2"></div> </body> </html>
结果图
2
个定位的元素都设置了z-index
属性,并且数值一样大还是后者会覆盖到前者。代码块
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>z-index属性</title> <style> div{ width: 200px; height: 200px; } .div1{ background-color: red; position: relative; top: 50px; left: 50px; z-index: 2; } .div2{ background-color: slateblue; position: relative; left: 100px; z-index: 2; } </style> </head> <body> <div class="div1"></div> <div class="div2"></div> </body> </html>
结果图
用实践来证明这句话,z-index
属性的属性值大的就会覆盖小,就是设置元素的层级。
代码块
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>z-index属性</title> <style> div{ width: 200px; height: 200px; } .div1{ background-color: red; position: relative; top: 50px; left: 50px; z-index: 3; } .div2{ background-color: slateblue; position: relative; left: 100px; z-index: 2; } </style> </head> <body> <div class="div1"></div> <div class="div2"></div> </body> </html>
结果图
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
css3 flex布局 justify-content:space-between 最后一行左对齐
网友评论