Home Web Front-end CSS Tutorial CSS common interview questions

CSS common interview questions

Aug 03, 2020 pm 03:22 PM
css interview questions

CSS common interview questions

##CSS introduction

1. Inline style, 2. Internal style Table, 3. External style sheet

link @import

a. link is an HTML tag, and @import is provided by CSS, and can only load CSS

b. The page is loaded , the link will be loaded at the same time, and the CSS referenced by @import will wait until the page is loaded before loading

c. import can only be recognized by IE5 or above, and link is an HTML tag, there is no compatibility issue

d. The weight of the link mode style is higher than the weight of @import

e. When using Javascript to control the DOM to change the style, you can only use the link mode, because @import only sees CSS. It is not DOM and can control

CSS basic selectors:

1. Tag selector element
2. Class selector (multiple class name selector).
3.id selector four
#4. Wildcard Selector*

##Special Recommendation

:Summary of CSS Interview Questions in 2020 (Latest)

CSS compound selector:
Descendant selector E>F

Child element selector
Intersection selector
Union selector,
Link pseudo-class selector lvha
Single colon ( :) is used for CSS3 pseudo-classes, and double colon (::) is used for CSS3 pseudo-elements

<ul> 
<p>111</p> 
<span>222</span> 
<li>1</li> 
<li>2</li> 
<li>3</li> 
</ul>
Copy after login
Copy after login

li:nth-of-type(2): indicates the second li element under ul

li :nth-child(2): Indicates that it is both a li element and the second element under ul (cannot be found).

It is recommended to generally use nth-of-type, which is less likely to cause problems.
Three major features of css: CSS cascading, CSS inheritance, CSS priority
Talk about your understanding of CSS layout

Box model

Clear the way of floating:

1. Extra tag method,

<p style="clear:both"></p>
Copy after login
Copy after login

2. Method of adding overflow attribute to parent

3. Use after pseudo-element to clear float

.clearfix:after {  content: ""; display: block; height: 0; clear: both; visibility: hidden;  }   .clearfix {*zoom: 1;}   /* IE6、7 专有 */。
Copy after login
Copy after login

4. Use double pseudo-element to clear float

Positioning mode and edge offset:

Display and hide elements:

display:none;

overflow:hidden

Mouse style cursor

default Xiaobai Default, pointer, move, text, not-allowed prohibit

vertical-align vertical alignment

Overflowing text ellipsis display

1.white-space:nowrap forces the text to be on one line Displayed on

2.overflow: hidden is hidden beyond part
3.text-overflow: ellipsis displays an omission mark when the text in the object overflows

Common layout methods:

Fixed layout,

Flow (%) layout,
Elastic (flex) layout,
rem layout
Floating layout, clear float
Positioning layout,
margin and padding

blocks Level element is vertically centered

How to center a p up, down, left and right

1.
left:50%; top:50%
transform: translate(-50%,-50%)
2 .
left:0; top: 0; bottom: 0; right: 0; margin: auto
3.px
Three major features of CSS: cascading inheritance priority
Inheritable properties
Text-related: font-family, font-size, font-style, font-variant, font-weight, font, letter-spacing, line-height, color

List-related: list-style-image, list-style-position, list-style-type, list-style

CSS3 new features

Realize rounded corners (border-radius), shadow (box-shadow), and add special effects to text (text- shadow), linear gradient (gradient), transformation (transform)


Added more CSS selectors multi-background rgba, the only pseudo-element introduced in CSS3 is ::selection, media query, multi-column layout

##CSS introduction1. Inline style, 2. Internal style sheet, 3. External style sheet

link @import
a. Link belongs to the HTML tag, while @import is provided by CSS, and can only load CSS

b. When the page is loaded, link will be loaded at the same time, and @import references The CSS will wait until the page is loaded before loading

c. import can only be recognized in IE5 or above, and link is an HTML tag, so there is no compatibility issue

d. The link style style has a high weight The weight of @import

e. When using Javascript to control the DOM to change the style, you can only use the link method, because @import only sees CSS, not the DOM that can control

CSS basics Selector:

1. Tag selector element

2. Class selector (multiple class name selector).

3. ID selector four
#4. Wildcard selector*

CSS compound selector:
Descendant selector E>F
Child element selector
Intersection selector
Union selector,
Link pseudo-class selector lvha
Single Colon (:) is used for CSS3 pseudo-classes, and double colon (::) is used for CSS3 pseudo-elements

<ul> 
<p>111</p> 
<span>222</span> 
<li>1</li> 
<li>2</li> 
<li>3</li> 
</ul>
Copy after login
Copy after login

li:nth-of-type(2): Represents the second li element under ul
li:nth-child(2): Indicates that it is both a li element and the second element under ul (cannot be found).
It is recommended to generally use nth-of-type, which is less likely to cause problems.
Three major features of css: CSS cascading, CSS inheritance, CSS priority
Talk about your understanding of CSS layout

Box model

Clear the way of floating:
1. Extra tag method,

<p style="clear:both"></p>
Copy after login
Copy after login

2. Method of adding overflow attribute to parent
3. Use after pseudo-element to clear float

.clearfix:after {  content: ""; display: block; height: 0; clear: both; visibility: hidden;  }   .clearfix {*zoom: 1;}   /* IE6、7 专有 */。
Copy after login
Copy after login

4. Use double pseudo-element to clear float

Positioning mode and edge offset:

Display and hide elements:
display:none;
overflow:hidden

Mouse style cursor
default Xiaobai Default, pointer, move, text, not-allowed prohibit
vertical-align vertical alignment

Overflowing text ellipsis display
1.white-space:nowrap forces the text to be on one line Displayed on
2.overflow: hidden is hidden beyond part
3.text-overflow: ellipsis displays an omission mark when the text in the object overflows

Common layout methods:
Fixed layout,
Flow (%) layout,
Elastic (flex) layout,
rem layout
Floating layout, clear float
Positioning layout,
margin and padding

blocks Level element is vertically centered
How to center a p up, down, left and right
1.
left:50%; top:50%
transform: translate(-50%,-50%)
2 .
left:0; top: 0; bottom: 0; right: 0; margin: auto
3.px
Three major features of CSS: cascading inheritance priority
Inheritable properties
Text-related: font-family, font-size, font-style, font-variant, font-weight, font, letter-spacing, line-height, color

List-related: list-style-image, list-style-position, list-style-type, list-style

CSS3 new features
Realize rounded corners (border-radius), shadow (box-shadow), and add special effects to text (text- shadow), linear gradient (gradient), transformation (transform)

Added more CSS selectors multi-background rgba, the only pseudo-element introduced in CSS3 is ::selection, media query, multi-column layout

Related tutorial recommendations: CSS video tutorial

The above is the detailed content of CSS common interview questions. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1659
14
PHP Tutorial
1258
29
C# Tutorial
1232
24
Google Fonts   Variable Fonts Google Fonts Variable Fonts Apr 09, 2025 am 10:42 AM

I see Google Fonts rolled out a new design (Tweet). Compared to the last big redesign, this feels much more iterative. I can barely tell the difference

How to Create an Animated Countdown Timer With HTML, CSS and JavaScript How to Create an Animated Countdown Timer With HTML, CSS and JavaScript Apr 11, 2025 am 11:29 AM

Have you ever needed a countdown timer on a project? For something like that, it might be natural to reach for a plugin, but it’s actually a lot more

HTML Data Attributes Guide HTML Data Attributes Guide Apr 11, 2025 am 11:50 AM

Everything you ever wanted to know about data attributes in HTML, CSS, and JavaScript.

A Proof of Concept for Making Sass Faster A Proof of Concept for Making Sass Faster Apr 16, 2025 am 10:38 AM

At the start of a new project, Sass compilation happens in the blink of an eye. This feels great, especially when it’s paired with Browsersync, which reloads

How We Created a Static Site That Generates Tartan Patterns in SVG How We Created a Static Site That Generates Tartan Patterns in SVG Apr 09, 2025 am 11:29 AM

Tartan is a patterned cloth that’s typically associated with Scotland, particularly their fashionable kilts. On tartanify.com, we gathered over 5,000 tartan

How to Build Vue Components in a WordPress Theme How to Build Vue Components in a WordPress Theme Apr 11, 2025 am 11:03 AM

The inline-template directive allows us to build rich Vue components as a progressive enhancement over existing WordPress markup.

PHP is A-OK for Templating PHP is A-OK for Templating Apr 11, 2025 am 11:04 AM

PHP templating often gets a bad rap for facilitating subpar code — but that doesn&#039;t have to be the case. Let’s look at how PHP projects can enforce a basic

Programming Sass to Create Accessible Color Combinations Programming Sass to Create Accessible Color Combinations Apr 09, 2025 am 11:30 AM

We are always looking to make the web more accessible. Color contrast is just math, so Sass can help cover edge cases that designers might have missed.

See all articles