CSSFlexを使用して要素をコンテナの下部に配置する方法
構文
CSSflexプロパティの構文は次のとおりです-
Selector {
flex: /*value*/
} 例
次の例は、CSSフレックスプロパティを示しています。
<!DOCTYPE html>
<html>
<head>
<style>
div {
display: flex;
flex-direction: column;
box-shadow: inset 0 0 6px aqua;
margin: 2%;
width: 30%;
height: 15%;
}
#d2, #d3 {
margin-left: 15%;
margin-top: 5%;
box-shadow: inset 0 0 6px green!important;
}
#d4 {
box-shadow: inset 0 0 6px red!important;
margin-top: auto;
}
</style>
</head>
<body>
<div id="container">
<div id="d1">Random text here..</div>
<div id="d2">Hello!!</div>
<div id="d3">Watch this</div>
<div id="d4">Example</div>
</div>
</body>
</html> これにより、次の出力が得られます
例
<!DOCTYPE html>
<html>
<head>
<style>
div {
display: flex;
flex-direction: column;
box-shadow: inset 0 0 6px red;
margin: 2%;
width: 30%;
}
#d2, #d3 {
margin-left: 15%;
border-radius: 50%;
padding: 5%;
box-shadow: inset 0 0 6px green!important;
}
#d4 {
margin-left: 50%;
margin-top: auto;
}
</style>
</head>
<body>
<div id="container">
<div id="d1"><img src="https://images.pexels.com/photos/5512653/pexels-photo-5512653.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940" /></div>
<div id="d2"></div>
<div id="d3"></div>
<div id="d4"><img src="https://images.pexels.com/photos/6032874/pexels-photo-6032874.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940" /></div>
</div>
</body>
</html> これにより、次の出力が得られます
-
CSSでhr要素のスタイルを設定するにはどうすればよいですか?
CSSを使用してhr要素のスタイルを設定するには、コードは次のとおりです- 例 <!DOCTYPE html> <html> <meta name="viewport" content="width=device-width, initial-scale=1"> <head> <style> body{ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-
-
CSSFlexを使用して列DIVを左-中央-右に揃える方法
フレックスコンテナのアイテムをその主軸に沿って配置し、その周りにスペースを分散させるには、CSSのjustify-contentプロパティを使用します。 構文 CSSjustify-contentプロパティの構文は次のとおりです- Selector { display: flex; justify-content: /*value*/ } 例 次の例は、CSSのjustify-contentプロパティを示しています。 <!DOCTYPE html> <html> <head>