用 CSS 設定盒子最多能有多寬


max-width 屬性用於設定一個盒子最寬能有多寬。max-width 屬性的值可以是數字、長度或百分比。

示例

<html>
   <head>
   </head>
   <body>
      <p style = "max-width:100px; height:200px; border:1px solid green; padding:5px; margin:10px;">
         This paragraph is 200px high and max width is 100px
         This paragraph is 200px high and max width is 100px
      </p>
      <img alt = "logo" src = "/css/images/logo.png" width = "100" height = "100" />
   </body>
</html>

更新時間: 04-Mar-2020

98 人瀏覽

開啟你的職業生涯

完成課程以獲得認證

入門
廣告