CSSは多くのテーマをカバーしており、開発者はすべてを完全に把握できません。すべての知識に習熟する必要はないのは事実ですが、一部のCSS基本知識が不可欠です。私の問題は、これらのコアナレッジポイントを中心に開発することです。
これらの問題は初心者には適していません。特定の経験があるだけで、これらの問題の意図をよりよく理解できます。
GitHubのプロジェクトの開発進捗状況に従うこともできます。
start!
注:「計算値」という用語を使用します。これは、開発者ツール「計算」タブに表示される属性値を指します。
次のセレクターの特性は何ですか?
:is(#container, .content, main) { color: red; }
<性>属性の計算値は:is()
です。正しいか間違っていますか? #container
@规则
color
セレクターの特性が高くなります。これが、<性>属性の計算値がred
である理由です。 .container { color: red; } :where(#container) { color: blue; }
:where()
.container
要素の<如果>属性がcolor
である場合、red
および
.container { display: inline; width: 1rem; height: 1rem; background-color: currentColor; }
属性計算値のアルゴリズムは何ですか? display
inline
width
height
ケース1:<元>要素はブロックレベルの要素です。それらの
.child
width
ケース2:<元>要素は弾性アイテムです。それらの<div class="parent"> <div class="child"></div> </div> <div class="parent-flex"> <div class="child"></div> </div>
.parent { display: block; } .parent-flex { display: flex; }
属性の計算値は何ですか? .child
width
width
<<>および
または<值>値は、子要素の.child
属性のwidth
属性の値を
display
および.parent { display: inline-grid; } .parent::before { content: ""; display: inline; } .parent::after { content: ""; display: flex; }
<>の親要素の内部では、サブエレメントが順番に表示されます。代わりに、<情况>の場合、要素は1つずつ表示されます。 block
.child
width
height
:is(#container, .content, main) { color: red; }
.container { color: red; } :where(#container) { color: blue; }
属性の計算値は1600pxです。 (ブラウザのデフォルトのフォントサイズが16px、100rem = 100 * 16px = 1600pxであると仮定).child
<>> <>、width
属性の親要素の内部は、すべてのスペースを埋めます。親要素に複数のアイテムがある場合、スペースは平均に割り当てられます。したがって、width
要素のwidth
属性の計算値は20REM / 2 = 10rem、つまり10 * 16 = 160pxです。
<素>要素の境界距離は、すべての場合において親要素を超えます。正しいか間違っていますか? display: grid
height
.child
height
エラー。
.child
サブマージー距離は、親要素を超えません。 .container { display: inline; width: 1rem; height: 1rem; background-color: currentColor; }
<div class="parent"> <div class="child"></div> </div> <div class="parent-flex"> <div class="child"></div> </div>
の要素の折りたたみですか? display: flex
display: inline-flex
いいえ、無効です。 display: grid
、<<>、display: inline-grid
、
display: inline-flex
擬似要素の位置は水平で垂直です。正しいか間違っていますか? display: inline-grid
正しい。ブラウザは、サブエレメントと親要素の間のすべてのスペースを割り当てます。 display: flex
display: inline-flex
<性>属性の計算値は何ですか? display: grid
display: inline-grid
.parent { display: block; } .parent-flex { display: flex; }
ただし、
、min-width
、.parent { display: inline-grid; } .parent::before { content: ""; display: inline; } .parent::after { content: ""; display: flex; }
<div class="parent"> <div class="child"></div> </div>
値が要素に対して定義されている場合、そのサブエレメントのmin-width
計算値は0です。 auto
.child
<属>属性をどのように使用してmin-width
属性を置き換えますか? auto
<元>要素のblock
属性を定義する必要があります。 inline
inline-block
<性>属性の計算値はtable
です。正しいか間違っていますか? table-*
min-width
gap
属性のすべてのmargin
値を代替値に変換します。 .parent { display: grid; width: 100rem; height: 20rem; }
要素の属性の計算値がなぜですか? .parent
gap
display
isolation
属性の役割は何ですか? :is(#container, .content, main) { color: red; }
.container { color: red; } :where(#container) { color: blue; }
z-index
属性が使用されるとき、ブラウザが使用するものを積み重ねるものを覚えておく必要があります。
デフォルトでは、ルートスタッキングコンテキストはhtml
要素です。これが、擬似要素が<情况>なしでisolation: isolate
要素の背後にある理由です。 .parent
isolation
.child
擬似要素の位置は何ですか? .parent
まず、まず、.container { display: inline; width: 1rem; height: 1rem; background-color: currentColor; }
の後、y軸に沿って親要素の下部の境界に移動します。これは、place-items: center
、
、position: absolute
属性の優先度があるためプロパティよりも高くなっています。 bottom: 0
top
<性>属性の計算値は何ですか? right
bottom
left
<性>属性の優先度はplace-items
属性よりも高くなりますが、その値はまた
width
<div class="parent"> <div class="child"></div> </div> <div class="parent-flex"> <div class="child"></div> </div>
flex-basis
CSSカスタム属性を使用する場合、すべての短縮部品を定義する必要があります。これを行わないと、ブラウザを使用できません。 width
min-width
これは私たちの例で起こりました。 max-width
略語には4つの値が必要ですが、3つの開発者のみが定義されています。ブラウザをセットアップできません。したがって、計算値は0です。
padding
属性の計算値があるのですか? .parent { display: block; } .parent-flex { display: flex; }
CSSカスタム属性は、親要素によって定義された同じカスタム属性継承値からなります。カスタム属性が省略されている場合、ブラウザは返品値を使用します。
私たちの例では、親要素からpadding
属性が省略されています。したがって、ブラウザは払い戻し値、つまり
p
background-color
この復活した出力は、元の画像のフォーマットを維持し、テキストをより簡潔で組織化した方法で提示します以上がCSSを知っている必要があります。あなたのCSSスキルをレベルアップするための私の質問の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。