Heim  >  Artikel  >  Web-Frontend  >  Legen Sie die maximale Breite einer Box mithilfe von CSS fest

Legen Sie die maximale Breite einer Box mithilfe von CSS fest

PHPz
PHPznach vorne
2023-09-01 15:45:07656Durchsuche

使用 CSS 设置框的最大宽度

Das max-width-Attribut wird verwendet, um die maximale Breite einer Box festzulegen. Der Wert des Attributs „max-width“ kann eine Zahl, eine Länge oder ein Prozentsatz sein.

Beispiel

<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>

Das obige ist der detaillierte Inhalt vonLegen Sie die maximale Breite einer Box mithilfe von CSS fest. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Stellungnahme:
Dieser Artikel ist reproduziert unter:tutorialspoint.com. Bei Verstößen wenden Sie sich bitte an admin@php.cn löschen
Vorheriger Artikel:Was ist iframe in CSS?Nächster Artikel:Was ist iframe in CSS?