Detailed analysis of new features in CSS3

Y2J
Release: 2017-05-20 11:50:52
Original
1602 people have browsed it

Note: Since CSS3 has many new features, it will be explained in two blog posts. The first article mainly includes new selectors, text and block shadows, multiple background images, color gradients, rounded corners, etc. The second article mainly details the variousanimationeffects of CSS3, such as: rotation, movement, scaling, etc., and also includes the application of icon fonts.

CSS3Attribute Selector:

a[href $='.pdf'] means that the href attribute ending with .pdf is selected

a[href^='mailto'] means that the href attribute starting with mailto is selected

a[href*='item'] means that all items containing item in the href attribute are selected

where a only refers to the element tag

There are three ps, and the values of their attribute names are different:

The style is as follows:

Join Selector:

Effect:

Add another attribute selector:

Effect:

I believe everyone is already familiar with the use of the selector, so it is relatively simple so I won’t go into details here. This kind of attribute selector is mostly used in thehrefattribute. It makes corresponding selections by loading different suffixes of the file name, such as: .jpg .png .gif, etc. .

CSS3 pseudoClass selector:

Existing oneTableis as follows:

#Join

pseudo-classSelector:

:nth-of-typeYou can select odd or even rows of the table through parameters,oddrepresents odd-numbered lines,evenrepresents even-numbered lines.

Effect:

:nth-childPseudo class, also used to select rows. When the parameter isn, all rows are selected. When the parameter isn+i, it means that all the following rows starting from theiline are selected,2nmeans that rows that are multiples of2are selected, that is, even-numbered rows.3nmeans that rows that are multiples of3are selected.

Effect:

n+i:

2n:

##3n:

There is also a:nth-last-child()pseudo-class, the usage is basically the same asnth-childThe same, except that all the rules are numbered from bottom to top, which is equivalent to turning the table upside down. There is no need to say more here, interested readers can try it themselves.

Multiple background images:

##backgroud-image## in CSS3 #You can set multiple background images, and you can also set the position of each background image.

Each background image has four parameters, 1.url

Address 2.Up and down position, including

topcenter bottom, you can also use percentage 3. Left and right position, includingleft center right, you can also use percentage4. Repeat method, includingno-repeat repeat-y repeat-x

. It's easy to understand, that is, no tiles, vertical tiles, and horizontal tiles.

(I’m being lazy and didn’t take any screenshots here. Readers can try their favoritepictures

)

---------- -------------------------------------------------- ----------------I am the dividing line-------------------------------- ------------------------------------

from here You should pay attention at the beginning. Since browsers with different cores have different support for CSS3, all subsequent features must be prefixed.

In the example below, the blogger did not add the prefix or only added the -webkit- prefix to save time.

The specific writing method is as follows:

##-webkit-

webkit

The core browser is Google’sChromebrowser;-moz-

Gecko

Core browser;-o-:

Opera

browser;-ms-: Microsoft The

IE

browser.Although a simple style needs to be written five times, it is the responsibility of the front-end engineer to ensure the compatibility of the web page. Each of the following features should be written according to the example when actually writing a web page, including the animation feature in the second blog post.

Text shadow:

Write ah1tag here first, the content This is a sentence that my teacher likes to use, please don’t complain...

Writing:

Text shadow Including 4 parameters, 1. Horizontal offset 2. Vertical offset 3. Blur radius (the higher the value, the blurrier, and vice versa) 4. Shadow color

Effect:

Setting a larger offset can produce the effect of floating and shadowing:

Is it like there is Light it down?

Set multiple shadows, separated by commas. The blur radius gradually increases, creating a glow effect.

The feeling of a light box

Set multiple shadows with different offset directions, and set them appropriately The color creates an embossed effect.

Block Shadow:

##Block shadows can be applied to many block-level elements

Now give me apAdd block shadow:

## Effect :

box-shadow

has 6 parameters. 1. Projection method (optional), do not write the default outer shadow,insetrepresents the inner shadow 2&3. Indicates the offset, similar to the text shadow 4. Blur radius (optional ) 5. Shadow expansion radius (optional), the larger the value, the greater the shadow range 6. Shadow colorInner shadow effect:

Existing red Circle:

Add multi-level block shadows, and the expansion radius gradually increases:

The sun comes out

Rounded corners:

The feature of rounded corners is very widely used, and you can also use rounded corners to draw circles.

#Apply to p:

##Effect:

border-radiusThe parameters can be 1 to 4:

1 parameter means that the value is applied to all four corners;2 parameters means that the first value is used for the upper left and lower right, and the first value is used for the upper right. , the second value is used for the lower left;

3 parameters indicate that the first value is used for the upper left, the second value is used for the upper right and lower left, and the third value is used for the lower right;

4 parameters The parameter indicates that the four values are used in the upper left, upper right, lower right, and lower left (counterclockwise).

Generally, 1 and 4 parameters are used more, and the others are a bit painful.

Four parameters:

Effect:

What about such rounded corners? Do?

It’s very simple, just make the value of the fillet equal to half the height of the p block:

Infers the use of rounded corners to draw a circle:

First build a square p block, and make its fillet value greater than or equal to half of its side length. , the sun in the above example was made in this way.

Gradient:

##Gradient is divided into two types: linear gradient and radial gradient

Linear gradient:

## Because when the gradient is drawn, it will be browsed The browser parses it into a background image, so backgroud-image is used when making gradients.

The first parameter of the gradient is the starting position:

leftmeans from left to righttopmeans from top to bottom, and so on . After that, you can set multiple colors, and after the color, you can set the starting position of the gradient (using percentage).

Effect:

Radial gradient, as the name suggests, is based on the radius of the circle Gradient:

##center

means the gradient starts from the center

Another sun comes out, Note that this is not done with shadows, but with radial gradients.

[Related recommendations]

1.

CSS3 free video tutorial

##2.Share a CSS3 animation library

3.CSS3 Learning Animation Detailed Explanation

4.CSS3 Teaching Animation Learning

5.Detailed explanation about the new features of css3

The above is the detailed content of Detailed analysis of new features in CSS3. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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 Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!