[CSS] clamp(min, current, max)

Browser support: https://caniuse.com/?search=clamp

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box1 {
        width: 50vw;
        height: 100px;
        background-color: red;
      }
      .box2 {
        width: clamp(200px, 50vw, 600px);
        height: 100px;
        background-color: blue;
      }
    </style>
  </head>
  <body>
    <h2>clamp() (值限制函数)</h2>
    <div class="box1"></div>
    <div class="box2"></div>
  </body>
</html>

 

posted @ 2025-05-27 19:38  Zhentiw  阅读(8)  评论(0)    收藏  举报