[CSS] text balance

Browser support: https://caniuse.com/css-text-wrap-balance

 

<!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: 300px;
        border: 1px black solid;
      }
      .box2 {
        width: 300px;
        border: 1px black solid;
        text-wrap: balance; /* 平衡:让文本在换行时尽量平均分布到每一行 */
        margin-top: 10px;
      }
    </style>
  </head>
  <body>
    <h2>Text balance (文字平衡)</h2>
    <div class="box1">
      Tailwind CSS works by scanning all of your HTML files, JavaScript
      components, and any other templates for class names, generating the
      corresponding styles and then writing them to a static CSS file.
    </div>
    <div class="box2">
      Tailwind CSS works by scanning all of your HTML files, JavaScript
      components, and any other templates for class names, generating the
      corresponding styles and then writing them to a static CSS file.
    </div>
  </body>
</html>

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