CSS covers many themes, and no developer can fully grasp everything. It is true that we do n’t need to be proficient in all knowledge, but some CSS basic knowledge is essential. My problem is to develop around these core knowledge points.
These problems are not suitable for beginners. You need at least one year of CSS experience, and it is better for two years. Only with certain experience can you better understand the intention of these issues.
You can also follow the development progress of the project on Github.
Start!
Note: I use the term "calculation value", which refers to the attribute values you see in the developer tool "Calculation" tab.
What is the characteristics of the following selector?
:is(#container, .content, main) { color: red; }
<性> The calculation value of the attribute is :is()
. Correct or wrong? #container
@规则
color
selector's characteristics are higher. This is why the calculation value of the <性> attribute is red
. .container { color: red; } :where(#container) { color: blue; }
:where()
.container
If the <如果> attribute of the element is color
, then red
and
.container { display: inline; width: 1rem; height: 1rem; background-color: currentColor; }
display
inline
width
Case 1: <元> Elements are block -level elements. Their height
attributes are equal to the
.child
Case 2: <元> Elements are elastic items. Their width
attributes are calculated according to the content. <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
<<> and width
.
value of the .child
attribute of the child element to the width
replacement value.
display
and .parent { display: inline-grid; } .parent::before { content: ""; display: inline; } .parent::after { content: ""; display: flex; }
Inside the parent element of <>, the sub -element will be displayed in order in order. Instead, in the case of <情况>, the elements will be displayed one by one. block
.child
and width
attributes of elements? height
:is(#container, .content, main) { color: red; }
.container { color: red; } :where(#container) { color: blue; }
attribute of the element is equal to the .child
attribute of the parent element. Therefore, the calculation value of the width
attribute is 1600px. (Assuming the default font size of the browser is 16px, 100rem = 100 * 16px = 1600px) width
width
Inside the parent element of <>,
attribute of the display: grid
element is 20rem / 2 = 10REM, that is, 10 * 16 = 160px. height
.child
<素> The border distance of the element will exceed the parent element in all cases. Correct or wrong? height
.child
Error. .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
Is the border folding in the elements of display: inline-flex
and display: grid
effective? display: inline-grid
display: inline-flex
and display: inline-grid
, the border distance will be accumulated. The position of pseudo elements is horizontal and vertical. Correct or wrong? display: flex
display: inline-flex
display: grid
Correct. The browser will allocate all the space between the sub -element and the parent element. display: inline-grid
.parent { display: block; } .parent-flex { display: flex; }
<初> is
. Therefore,min-width
calculation value of the element is .parent { display: inline-grid; } .parent::before { content: ""; display: inline; } .parent::after { content: ""; display: flex; }
<div class="parent"> <div class="child"></div> </div>
, min-width
, auto
, .child
or min-width
values are defined for elements, then the auto
calculation value of its sub -element is 0.
How do we use <属> attributes to replace block
attributes? inline
inline-block
table
We should define table-*
attributes for <元> element. min-width
gap
margin
.parent { display: grid; width: 100rem; height: 20rem; }
value of the .parent
attribute to gap
alternative value.
display
attributes of <素> element? block
<div class="parent"> <div class="child"></div> </div>
Elements with <<> or absolute
will be removed from the normal document stream. Therefore, the parent element cannot see it. This is why the calculation value of the <性> attribute is 0. fixed
isolation
attributes? :is(#container, .content, main) { color: red; }
.container { color: red; } :where(#container) { color: blue; }
We should remember that when the z-index
attribute is used, what stack the browser uses.
By default, the roots stacking context is html
element. This is why the pseudo element is behind the isolation: isolate
element without <情况>. .parent
elements. Therefore, the pseudo element is displayed behind the text, but in front of the isolation
element. .child
.parent
What is the location of the pseudo element?
.container { display: inline; width: 1rem; height: 1rem; background-color: currentColor; }
place-items: center
After the application <<> and
, position: absolute
, bottom: 0
and top
attributes is higher than right
property. bottom
left
<性> What is the calculation value of the attribute? place-items
width
attributes, but its values must also be within the range of <div class="parent"> <div class="child"></div> </div> <div class="parent-flex"> <div class="child"></div> </div>
flex-basis
<性> What is the calculation value of the attribute? width
min-width
max-width
When using CSS custom attributes, we should define all the abbreviated parts. If we don't do this, the browser cannot be used.
padding
The abbreviation requires 4 values, but only 3 developers are defined. The browser cannot be set up. Therefore, the calculation value is 0. .parent { display: block; } .parent-flex { display: flex; }
attribute of the <素> element?
padding
CSS custom attributes will from the same custom attribute inheritance values defined by parent elements. If the custom attribute is omitted, the browser will use the return value.
p
attribute is omitted from the parent elements. Therefore, the browser uses the refund value, that is, the background-color
keyword, the keyword from the .parent { display: inline-grid; } .parent::before { content: ""; display: inline; } .parent::after { content: ""; display: flex; }
This Revied Output Maintains The Original Image Formatting and Avoids Significant Alterations to the Meaning While Rephrasing The Text For Improved LITY and Flow. The Questions are presented in a more concise and organized manner.
The above is the detailed content of You Should Know CSS. My questions to level up your CSS skill. For more information, please follow other related articles on the PHP Chinese website!