使用 CSS 设置元素的最小宽度和最大宽度

cssweb developmentfront end technology更新于 2024/4/5 19:24:17

要设置元素的最小宽度和最大宽度,您可以尝试运行以下代码

示例

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            max-width: 300px;
            min-width: 100px;
            background-color: red;
         }
      </style>
   </head>
   <body>
      <p> Below is a div with maximum and minimum width. Resize the web browser to see the effect.</p>
      <div>This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text.
      </div>
   </body>
</html>

输出


相关文章


有用资源