positionFixed测试.html 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>position fixed 测试</title>
  8. </head>
  9. <body>
  10. <div class="parent bg">
  11. parent box
  12. <div class="fixed-box">
  13. width: 100%;<br/>
  14. height: 100%;<br/>
  15. background-color: red;<br/>
  16. opacity: 0.4;<br/>
  17. position: fixed;<br/>
  18. left: 20px;<br/>
  19. top: 50px;<br/>
  20. </div>
  21. </div>
  22. </body>
  23. <style>
  24. *{
  25. padding:0;
  26. margin: 0;
  27. }
  28. body{
  29. width: 100%;
  30. height: 100vh;
  31. background-color: #ebe9cc;
  32. display: flex;
  33. justify-content: center;
  34. align-items: center;
  35. }
  36. .bg{
  37. background-color: rgba(89, 89, 89, 0.1);
  38. backdrop-filter: blur(30px);
  39. -webkit-backdrop-filter: blur(30px);
  40. border: 1px solid rgba(255, 255, 255, 0.18);
  41. box-shadow: rgba(14, 14, 14, 0.19) 0px 6px 15px 0px;
  42. -webkit-box-shadow: rgba(14, 14, 14, 0.19) 0px 6px 15px 0px;
  43. border-radius: 4px;
  44. -webkit-border-radius: 4px;
  45. /*color: rgba(128, 128, 128, 0.4);*/
  46. }
  47. .parent{
  48. width: 80%;
  49. height: 80%;
  50. border: 1px solid black;
  51. }
  52. .fixed-box{
  53. width: 100%;
  54. height: 100%;
  55. background-color: red;
  56. opacity: 0.4;
  57. position: fixed;
  58. left: 20px;
  59. top: 50px;
  60. }
  61. </style>
  62. </html>