<!DOCTYPE html>
<html lang='en'>
<head>
  <meta charset='UTF-8'>
  <meta name='author' content='Xue Huanqun'>
  <title>p72_73</title>
  <style type='text/css'>
    .relativeBlock{
      width: 600px;
      height: 300px;
      background-color: #0077b6;
      position: relative;
      margin-top: 200px;
    }
    .absoluteBlock{
      width: 50px;
      height: 50px;
      background-color: #90e0ef;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      border-radius: 50%;
    }
    .fixedBlock{
      width: 20px;
      height: 100px;
      background-color: #f94144;
      position: fixed;
      top: 20px;
      right: 20px;
      border-radius: 10px;
      box-shadow: 0 0 10px #f94144;
    }
  </style>
</head>
<body>
  <div class='relativeBlock'>
    <div class='absoluteBlock'>
<pre><code>&lt;/div&gt;
</code></pre>
  </div>
  <div class='fixedBlock'>
</div>
</body>
</html>
CSS 绝对定位、固定定位:样式修改示例

原文地址: https://www.cveoy.top/t/topic/gnyr 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录