别看等级
Java后端
·2023-02-08
前端 #提问# 为什么交换两个盒子顺序,右边的盒子消失 是什么原理 打印zIndex也没东西显示 <!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>固定定位小技巧-固定到版心右侧</title> <style> .w { width: 800px; height: 1400px; background-color: pink; margin: 0 auto; } .fixed { position: fixed; /* 1. 走浏览器宽度的一半 */ left: 50%; /* 2. 利用margin 走版心盒子宽度的一半距离 */ margin-left: 405px; width: 50px; height: 150px; background-color: skyblue; } </style> </head> <body> <div class="w">版心盒子 800像素</div> <div class="fixed"></div> <script> var w = document.querySelector(".w") console.log(w.style.zIndex) var fixed = document.querySelector(".fixed") console.log(w.style.zIndex) </script> </body> </html>
0个评论
点击登录,快来和大家讨论吧~
表情
图片
暂无评论
下载 APP