TIL 005 CS Responsive Unit(応答単位)
🎯 水がいっぱい入ったコップのように、反応型サイトに提供される設備を学びましょう。
1. Absolute length units
px
画面上の最小ディスプレイユニット
2. Relatvie length units
em

rem

vw
vh
%
👀 それぞれいつ使えばいいですか?


💦反応単位の利用
1) em for padding
2) em vs rem for padding
titleとcontentsのフォントサイズが異なるremを使用する場合、padding値の設定例

html
<section class="component">
<header class="title">Master Front-end ✨</header>
<p class="contents">
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Sapiente
veniam, nulla porro distinctio aliquid, quos quidem odio consectetur
aperiam, delectus cum. Deserunt facilis excepturi similique natus minus
deleniti rem sit?
</p>
</section>
CSS
.component {
width: 50%;
border: 1px solid red;
font-size: 2rem;
}
.title {
backgorund-color: red;
}
.contents {
font-size: 1rem;
}
@media screen and (max-width: 48rem) {
.component {
font-size: 1.5rem;
}
}
.title {
padding: 0.5em;
background-color: burlywood;
}
.contents {
font-size: 1rem;
padding: 0.5em;
}

em充填を使用するのは良いですが、各要素が固定的な充填を維持する必要がある場合はremを使用するのが望ましいです.
左揃えrem、上下揃えemは、現在のフォントサイズの影響を受けずにすべての要素を垂直に揃えます.

.title {
padding: 0.5em 0.5rem;
background-color: burlywood;
}
.contents {
font-size: 1rem;
padding: 0.5em 0.5rem;
}
Media query設定によりスクリーン幅が48 remに対して変化した場合は、左右、上下の塗りつぶし値をチェックしてください!

1. たんいけいさんき
2. エンコードサムネイル-単位サンプルビデオ
Reference
この問題について(TIL 005 CS Responsive Unit(応答単位)), 我々は、より多くの情報をここで見つけました https://velog.io/@aliceinkorea/TIL-005-ResponsiveUnits-CSSテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol