「CSS」min-widthプロパティで最小の幅を指定する

2021年9月15日

書式
min-width: 数値px;
min-width: 数値em;
min-width: パーセント値
min-width: 40ch;
min-width は CSS のプロパティで、要素の最小幅を設定します。
これは width プロパティの使用値が、min-width で指定した値を下回ることを防ぎます。
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<style>
.cftA {
width: 250px;
border: 1px solid red;
}
.cftB {
width: 40%;
min-width: 150px;
border: 1px solid #000;
background-color: skyblue;
}
</style>
<div class="cftA">aaa11111
<div class="cftB">bbbbbbbbbbb</div>
</div>
<style> .cftA { width: 250px; border: 1px solid red; } .cftB { width: 40%; min-width: 150px; border: 1px solid #000; background-color: skyblue; } </style> <div class="cftA">aaa11111 <div class="cftB">bbbbbbbbbbb</div> </div>
<style>
  .cftA {
    width: 250px;
    border: 1px solid red;
  }
  .cftB {
    width: 40%;
    min-width: 150px;
    border: 1px solid #000;
    background-color: skyblue;
  }
</style>
<div class="cftA">aaa11111
  <div class="cftB">bbbbbbbbbbb</div>
</div>

 

CSS

Posted by arkgame