(2) How to clear floats?
1. Box model in CSS3 There are two types of box models in CSS3: standard box model and IE box model##Special recommendation:2020 CSS interview questions summary (latest)
box-sizing:border-boxto convert the ordinary box model into an IE box model. Sometimes we have set the width and height of a box, but if we want to change
border, so that the size of the box will change, we can convert it into an IE box model without having to change it every time. Calculate the size of the box contents.
Represents the standard box model (default value)
Represents the IE box model (that is, the weird box model)
Flex Flexible Box Model
##2. The difference between display:none and visibility:hidden
(1)In the rendering tree
hidden
. By settingvisibility:visible
, the descendant nodes can be displayed. .
of an element in the regular document flow will usually cause the document to be rearranged, but modifying thevisibility
attribute will only cause the element to be Redraw(4) If a screen reader is used, the content set to
will not be read, and the content set tovisibility:hidden
will be read.visibility:hidden
3. Let’s talk about the CSS sprite
The sprite is Splice multiple small pictures into one picture. When using, adjust the background pattern to be displayed through the
background-positionelement size.
Reduce the number of HTTP requests and improve the loading speed of the page to a certain extent
Attribute value | Overview |
---|---|
Generate Absolutely positioned elements are positioned relative to a parent element other than static positioning | |
Generate relatively positioned elements, positioned relative to their original position | |
Generate absolutely positioned elements, positioned relative to the browser window | |
Default value, no positioning, the element appears in the normal document flow | |
Specifies that the value of the position attribute is inherited from the parent element |
Suitable for: simple color logos, icons, wireframes, simple animations
(2)JPGApplicable In: Colorful pictures, gradient images
(3) PNG: APP or webpage that supports webp
Advantages | Disadvantages | Applicable scenarios | |
---|---|---|---|
Small file size, supports animation, transparency, no compatibility Problem | Only supports 256 colors | Simple colors for logos, icons, and animations | |
Rich colors, files Small | Lossy compression, repeated saving of pictures reduces the quality obviously | Colorful pictures/gradient images | |
Lossless Compression, support transparency, simple pictures are small in size | Does not support animation, colorful pictures are in large size | logo/icon/transparent picture | ##webp |
Browser compatibility is not good | Supports apps and webviews in webp format |
##Class selector | #myclassname | ||||||||||||||||||||||||||||||||||||||||||||||||||
##id selector | #myid | ||||||||||||||||||||||||||||||||||||||||||||||||||
Adjacent sibling selector | h1 p | ||||||||||||||||||||||||||||||||||||||||||||||||||
Child selector | ul>li | ||||||||||||||||||||||||||||||||||||||||||||||||||
Descendant selector | li a | ||||||||||||||||||||||||||||||||||||||||||||||||||
Wildcard selector | * | ||||||||||||||||||||||||||||||||||||||||||||||||||
Attribute selector | a[ref="eee"] | ||||||||||||||||||||||||||||||||||||||||||||||||||
Pseudo-class selector | li:last-child | ||||||||||||||||||||||||||||||||||||||||||||||||||
If you need to select an element immediately after another element, and both have the same parent element, you can use the adjacent sibling selector. For example, if you want to increase the top margin of the paragraph that appears immediately after the h1 element , you can write like this: h1 + p {margin-top:50px;}
Copy after login
Copy after login
For thepriority of the selector:
It should be noted that:
Attribute inheritance:
7. After floating-relatedelements are set to float, the display will automatically become block. (1) When do I need to clear floats?The problems caused by floating are as follows:
(2) How to clear floats?The way to clear floats is as follows:
Flex Flexible Box Model ##2. The difference between display:none and visibility:hidden These two attributes are to let the element Hide invisibleDifference:(1)In the rendering tree
of an element in the regular document flow will usually cause the document to be rearranged, but modifying the will not be read, and the content set to 精灵图就是将多个小图片拼接在一个图片中,使用的时候通过 优点:
缺点:
4. What are the attribute values of position?##absoluteGenerate Absolutely positioned elements are positioned relative to a parent element other than static positioningrelativeGenerate relatively positioned elements, positioned relative to their original positionfixedGenerate absolutely positioned elements, positioned relative to the browser windowstaticDefault value, no positioning, the element appears in the normal document flowinheritSpecifies that the value of the position attribute is inherited from the parent element
Suitable for: simple color logos, icons, wireframes, simple animations (2)JPG
Applicable In: Colorful pictures, gradient images (3) PNG
: APP or webpage that supports webp
The above is the detailed content of Seven Important CSS Interview Questions. For more information, please follow other related articles on the PHP Chinese website!
Related labels:
source:csdn.net
Previous article:Organize common css interview questions
Next article:2019 CSS classic interview questions
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
Latest Articles by Author
Latest Issues
PHP trim unicode spaces
I'm trying to trim unicode spaces such as this character and I was able to do it using thi...
From 2023-11-13 08:49:45
0
2
398
Related Topics
More>
|