CSS
 Computer >> コンピューター >  >> プログラミング >> CSS

CSSを使用して要素の最小幅と最大幅を設定します


要素の最小幅と最大幅を設定するには、次のコードを実行してみてください

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

出力

CSSを使用して要素の最小幅と最大幅を設定します


  1. CSSを使用して要素をZ-Indexとオーバーラップさせる

    CSS Z-Indexプロパティの開発者は、要素を相互にスタックできます。 Z-Indexには、正の値または負の値を指定できます。 注 −重複する要素にz-indexが指定されていない場合、その要素はドキュメントの最後に記載されている要素として表示されます。 例 z-indexプロパティの例を見てみましょう- <!DOCTYPE html> <html> <head> <style> p {    margin: 0;    position: absolute;    to

  2. CSSを使用して要素のテキストの色を設定する

    CSSのcolorプロパティは、要素のテキストの色を変更するために使用されます。値は、標準の色名、rgb()、rgba()、hsl()、hsla()、および16進値として指定できます。 構文 CSScolorプロパティの構文は次のとおりです- Selector {    color: /*value*/ } 次の例は、CSSカラープロパティ-を示しています。 例 <!DOCTYPE html> <html> <head> <style> div {    height: 50px;   &nb