CSS表示プロパティの操作
CSS Displayプロパティは、要素がWebページにどのように表示されるかを設定するために使用されます。その値の一部がここに表示されます-
| Sr.no | プロパティ値 | 説明 |
|---|---|---|
| 1 | インライン | 要素をインライン要素として表示します。 |
| 2 | ブロック | 要素をブロック要素として表示します。 |
| 3 | コンテンツ | コンテナを非表示にして、要素の子要素をDOMの次のレベルの子にします |
| 4 | フレックス | 要素をブロックレベルのフレックスコンテナとして表示します |
| 5 | グリッド | 要素をブロックレベルのグリッドコンテナとして表示します |
| 6 | インラインブロック | 要素をインラインレベルのブロックコンテナとして表示します。 |
| 7 | インラインフレックス | 要素をインラインレベルのフレックスコンテナとして表示します |
| 8 | インライングリッド | 要素をインラインレベルのグリッドコンテナとして表示します |
| 9 | インラインテーブル | 要素はインラインレベルのテーブルとして表示されます |
例
CSS表示プロパティを実装する例を見てみましょう-
<!DOCTYPE html>
<html>
<head>
<style>
span {
background-color: orange;
color: white;
}
p.demo {
display: none;
}
span.demo1 {
display: inline;
}
</style>
</head>
<body>
<h1>Match Details</h1>
<div>
Match will begin at <p class="demo">9AM</p> 10AM on 20th December.
</div>
<div>
Match will end at <span class="demo1">5PM</span> on 20th December.
</div>
</body>
</html> 出力
例
別の例を見てみましょう-
<!DOCTYPE html>
<html>
<head>
<style>
p {
background-color: orange;
color: white;
}
p.demo1 {
display: block;
}
p.demo2 {
display: inline-block;
}
</style>
</head>
<body>
<h1>Match Details</h1>
<div>
Match will begin at <p class="demo1">10AM</p> on 19th Decemenber, 2019.
</div>
<div>
Match will end at <p class="demo2">5PM</p> on 19th Decemenber, 2019.
</div>
</body>
</html> 出力
-
CSSでホバー時に要素を表示するにはどうすればよいですか?
CSSを使用してホバーで要素を表示するには、コードは次のとおりです- 例 <!DOCTYPE html> <html> <head> <style> body{ margin:20px; padding:20px; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
-
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-