An adaptive and easy-to-use CSS

Time:2021-10-14

Mainly using CSS

max-width:min-content

The following code shows

<!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>
    .box{
      width: 100px;
    }
    .boxMain{
      display: flex;
      justify-content: space-between;
      padding: 2px 8px;
      border: 1px solid #ccc;
      background-color: aqua;
      overflow: hidden;
      color: #fff;
      width: 100%;
      max-width: min-content;
    }
    .l{
      max-width: min-content;
      /*Overflow is displayed with an ellipsis*/
      text-overflow: ellipsis;
      overflow: hidden;
      /*Overflow does not wrap*/
      white-space: nowrap;
    }
  </style>
</head>
<body>
    <div class="box">
      <div class="boxMain">
        < div class = "L" > CSS adaptive style max width: Min content < / div >
        <div class="r">>>></div>
      </div>
    </div>
  
</body>
</html>

By changing the width of the. Box, you can see that the interior changes as the width increases or decreases

An adaptive and easy-to-use CSS