CSSのmin-widthプロパティ
CSSのmin-widthプロパティを使用して、要素のコンテンツボックスに固定の最小幅を定義できます。これにより、幅が最小幅よりも小さい場合でも、要素のコンテンツボックスを狭くすることはできません。
構文
CSSのmin-widthプロパティの構文は次のとおりです-
Selector {
min-width: /*value*/
} 例
CSSのmin-widthプロパティの例を見てみましょう-
<!DOCTYPE html>
<html>
<head>
<title>CSS min-width Property</title>
</head>
<style>
* {
padding: 2px;
margin:5px;
}
button {
border-radius: 10px;
}
#containerDiv {
width:70%;
margin: 0 auto;
padding:20px;
background-image: linear-gradient(135deg, #dc3545 0%, #9599E2 100%);
text-align: center;
border-radius: 10px;
}
.contentDiv{
min-width:200px;
border: 1px solid black;
}
</style>
<body>
<div id="containerDiv">
<div class="contentDiv">
This is paragraph 1 with some dummy text.
</div>
<div class="contentDiv">
This is paragraph 2 with some dummy text.
</div>
<div class="contentDiv">
This is paragraph 2 with some dummy text.
</div>
<button onclick="add()" class="btn">Set minWidth</button>
</div>
<script>
function add() {
document.querySelectorAll('.contentDiv')[1].style.minWidth = "100%";
}
</script>
</body>
</html> 出力
上記のコードの出力は次のとおりです-
[minWidthの設定]をクリックする前に ボタン-
[minWidthの設定]をクリックした後 ボタン-
例
CSSのmin-widthプロパティの別の例を見てみましょう-
<!DOCTYPE html>
<html>
<head>
<title>CSS min-width Property</title>
</head>
<style>
* {
padding: 2px;
margin:5px;
}
button {
border-radius: 10px;
}
#containerDiv {
width:70%;
margin: 0 auto;
padding:20px;
background-image: linear-gradient(62deg, #fbab7e 0%, #f7ce68 100%);
text-align: center;
border-radius: 10px;
}
.contentDiv{
min-width:200px;
border: 1px solid black;
}
</style>
<body>
<div id="containerDiv">
<div class="contentDiv">
This is paragraph 1 with some dummy text.
</div>
<div class="contentDiv">
Lorem Text
</div>
<div class="contentDiv">
This is paragraph 3 with some dummy text.
</div>
<button onclick="add()" class="btn">Set minWidth</button>
</div>
<script>
function add() {
var all = document.querySelectorAll('.contentDiv');
for(var i=0; i<all.length; i++)
all[i].style.minWidth = "100%";
}
</script>
</body>
</html> 出力
上記のコードの出力は次のとおりです-
[minWidthの設定]をクリックする前に ボタン-
[minWidthの設定]をクリックした後 ボタン-
-
CSSのborder-colorプロパティ
CSSのborder-colorプロパティは、要素の境界線の色を指定するために使用されます。また、border-top-color、border-right-color、border-left-color、border-right-colorプロパティを使用して、個々の辺の色を設定することもできます。 構文 CSSborder-colorプロパティの構文は次のとおりです- Selector { border-color: /*value*/ } 次の例は、CSSのborder-colorプロパティ-を示しています。 例 <!DOCTYPE html>
-
CSSのborder-styleプロパティ
CSS border-styleプロパティは、要素の境界線スタイルを指定するために使用されます。また、border-topスタイル、border-rightスタイル、border-leftスタイル、border-rightスタイルのプロパティを使用して、個々の辺の境界線スタイルを定義することもできます。 構文 CSSボーダープロパティの構文は次のとおりです- Selector { border: /*value*/ } 次の例は、CSSボーダースタイルのプロパティ-を示しています。 例 <!DOCTYPE html> <html> <