CSSで行の高さを設定する
線の高さは、CSSのline-heightプロパティで定義できます。正の値のみを受け入れます。
構文
CSSのline-heightプロパティの構文は次のとおりです-
Selector {
line-height: /*value*/
} 例
次の例は、CSSのline-heightプロパティを示しています。
<!DOCTYPE html>
<html>
<head>
<style>
div * {
margin: 1.5em;
box-shadow: -13px -10px 10px 1px crimson;
}
#demo {
line-height: 60%;
}
p {
box-shadow: 13px -10px 10px 1px grey;
line-height: 50px;
}
</style>
</head>
<body>
<h2>Demo Heading</h2>
<div>
<p>This is demo text one.</p>
<div>This is demo text two.</div>
<div id="demo">This is demo text three.</div>
</div>
</body>
</html> 出力
これにより、次の出力が得られます-
例
<!DOCTYPE html>
<html>
<head>
<style>
div * {
margin: auto;
padding: 3em;
}
p {
height: 100px;
width: 100px;
border: thin solid;
border-radius: 50%;
box-shadow: 0 20px 10px 1px grey;
line-height: 0.6;
}
</style>
</head>
<body>
<h2>What is C#?</h2>
<div>
<p>C# is a strongly-typed language. Every variable and constant has a type, as does every expression that evaluates to a value.</p>
</div>
</body>
</html> 出力
これにより、次の出力が得られます-
-
CSSの要素の幅と高さ
CSSのheightプロパティとwidthプロパティは、要素の高さと幅をそれぞれ指定するために使用されます。 max-height、max-width、min-height、およびmin-widthプロパティを使用して、これらのプロパティの最大値と最小値を設定することもできます。 構文 CSSの高さとCSSの幅のプロパティの構文は次のとおりです- Selector { height: /*value*/ width: /*value*/ } 要素の実際の幅と高さは次のように計算されます- ボックスサイズ 計算 全幅 幅+パディン
-
CSSでのカラープロパティの設定
CSSを使用して、要素のテキスト、境界線、背景の色を定義できます。 colorプロパティは、要素のテキストの色を指定するために使用されます。 構文 CSScolorプロパティの構文は次のとおりです- Selector { color: /*value*/ } 次の例は、CSSカラープロパティ-を示しています。 例 <!DOCTYPE html> <html> <head> <style> div { color: seashell; background-color