search
HomeWeb Front-endCSS TutorialSome new features of css3

Some new features of css3

Nov 24, 2016 am 11:08 AM
css3

background:rgba(254, 255, 200, 0.75);

For example, as shown in the above code, the first three parameters are the three primary colors of R, G, and B, and the range is 0-255. The fourth parameter is background transparency, ranging from 0-1, such as 0.5 representing 50% transparency. This attribute allows us to achieve a translucent glass effect like Win7 in the browser.

css3 rounded corner sample code

/*FireFox syntax*/

-moz-border-radius: 6px 6px 6px 6px;

-moz-border-radius-topright: 6px;

-moz -border-radius-topleft: 6px;

-moz-border-radius-bottomright: 6px;

-moz-border-radius-bottomleft: 6px;

/*WebKit core browser syntax*/

-webkit-border-radius: 6px 6px 6px 6px;

-webkit-border-top-right-radius: 6px;

-webkit-border-top-left-radius: 6px;

-webkit-border-bottom -right-radius: 6px;

-webkit-border-bottom-left-radius: 6px;

/*CSS standard syntax*/

border-radius:6px 6px 6px 6px;

border-top- right-radius: 6px;

border-top-left-radius: 6px;

border-bottom-right-radius: 6px;

border-bottom-left-radius: 6px;

As shown in the above code, The effect of the four corners can be specified by a line of code border-radius: 6px 6px 6px 6px, where the four parameters represent from left to right: upper left corner, upper right corner, lower right corner, and lower left corner. You can also specify the effect of each corner separately like border-top-right-radius: 6px;.

Gradient color

background: -moz-linear-gradient(

center top,/* The coordinates of the gradient start*/

rgba(254, 216, 80, 0.75),/* The gradient start color */

rgba(230, 125, 30, 0.75) 50%,/* Middle gradient color*/ www.2cto.com

rgba(254, 235, 121, 0.75)/* Gradient end color*/ ) repeat scroll 0 0 transparent;

As shown in the above code, Mozilla uses the -moz-linear-gradient tag to represent linear gradients. The first parameter represents the coordinate where the gradient starts, which can be a coordinate value, or a value such as top, bottom, left, right, center, etc. The following parameters are the color values ​​of the gradient, there is no limit to the number, and they are separated by commas. Each color value can be a normal hexadecimal color or an RGBA color value. Each color can also be followed by a percentage or a decimal between 0-1, indicating the proportion of that color in the entire gradient.

Webkit gradient syntax

background:-webkit-gradient(

linear,/* gradient type linear*/

left top,/* coordinates where the gradient starts*/

left bottom, /* The coordinates of the end of the gradient*/

from(rgba(254, 216, 80, 0.75)),/* The starting color of the gradient*/

to(rgba(254, 235, 121, 0.75)),/* Gradient End color*/

color-stop(0.5,rgba(230, 125, 30, 0.75))/* Middle color of gradient*/

)

repeat scroll 0 0 transparent;

Webkit browser uses -webkit The -gradient attribute represents a gradient. The first parameter is the gradient type, usually linear. The second parameter is the coordinate where the gradient starts, the same as Mozilla's first parameter. The third parameter is the coordinate of the end of the gradient. The fourth and fifth are the start and end colors of the gradient respectively, which can be hexadecimal color values ​​or RGBA color values. There can be an infinite number of final color-stop attributes, separated by commas after the first five parameters, indicating the gradient color in the middle of the change. In the color-stop attribute, the first parameter is the proportion of the gradient color, which can be a decimal from 0-1 or a percentage; the second parameter is the color value of the gradient, which can also be a hexadecimal color. value or RGBA color value.

Transform

Transform is another blockbuster of CSS after linear color gradient. Usually using CSS and HTML, it is impossible for us to rotate or tilt HTML elements at a certain angle. In order to make the element look more three-dimensional, we have to make this effect into a picture, which limits many dynamic application scenarios. The introduction of the Transform attribute enables functions that we usually had to use vector drawing methods such as SVG to achieve with just a simple CSS attribute. In CSS3, Transform properties mainly include rotate rotation, scale scaling, translate coordinate translation, skew coordinate tilt, and matrix matrix transformation. Let's take a look at how each attribute is used.

/*Webkit Core Browser*/

-webkit-transform: rotate(-90deg);

-webkit-transform: scale(2);

-webkit-transform: scale(2, 1);

-webkit-transform: translate(10px, 20px);

-webkit-transform: skew(30deg, -10deg);

-webkit-transform: matrix(1, -0.2, 0, 1, 0, 0);

/*Firefox browser*/

-moz-transform: rotate(-90deg);

-moz-transform: scale(2);

-moz-transform: scale(2, 1);

-moz-transform: translate(10px, 20px);

-moz-transform: skew(30deg, -10deg);

-moz-transform: matrix (1, -0.2, 0, 1, 0, 0);

/*Opera browser*/

-o-transform: rotate(-90deg);

-o-transform: scale(2);

-o-transform: scale(2, 1);

-o-transform: translate(10px, 20px);

-o-transform: skew(30deg, -10deg);

-o-transform: matrix (1, -0.2, 0, 1, 0, 0);

The rotation attribute code is very simple. The rotate attribute plus the rotation angle parameter, 45deg represents a 45-degree clockwise rotation. If it is rotated 45 degrees counterclockwise it is -45deg.

Similar to rotation, the scaling attribute is implemented by the scale keyword plus the scaling parameter. When there is only one parameter 2, it means that the X-axis and Y-axis directions of the HTML element are enlarged by 2 at the same time, and 0.5 means that it is reduced by half at the same time. If there are two parameters of 2 and 3 at the same time, it means that the X axis of the HTML element is enlarged by 2 and the Y axis direction is enlarged by 3.

As the name suggests, the coordinate translation attribute is to translate the HTML element by a number of pixels in the X and Y axis directions, which is implemented by the translate attribute. The latter two parameters represent the amount of translation to the X-axis and Y-axis respectively. The

skew property is also a useful transform function, which can tilt an object at a certain angle around the X and Y axes. This is different from the rotation of rotate. Rotate only rotates without changing the shape of the HTML element, while skew will change the shape of the HTML element. skew has two parameters, representing the tilt of the HTML element along the X and Y axes.

Matrix, you read that right, it is our usual matrix transformation. This transformation is the coordinate system transformation we learned in analytic geometry. It has six parameters (a, b, c, d, e, f) and is a 3 × 3 matrix representing the transformation matrix of coordinate transformation. Using it, we can flexibly complete any coordinate system transformation. Friends who are interested can check the college analytic geometry textbook, or W3c's definition and description of Matrix changes in SVG.

Currently, the browsers that support these 5 conversion attributes are Safari 4+, Chrome 5+, Firefox 3.5+, and Opera 10.5+. The entire IE browser series does not support this attribute.


Statement
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
What is CSS Grid?What is CSS Grid?Apr 30, 2025 pm 03:21 PM

CSS Grid is a powerful tool for creating complex, responsive web layouts. It simplifies design, improves accessibility, and offers more control than older methods.

What is CSS flexbox?What is CSS flexbox?Apr 30, 2025 pm 03:20 PM

Article discusses CSS Flexbox, a layout method for efficient alignment and distribution of space in responsive designs. It explains Flexbox usage, compares it with CSS Grid, and details browser support.

How can we make our website responsive using CSS?How can we make our website responsive using CSS?Apr 30, 2025 pm 03:19 PM

The article discusses techniques for creating responsive websites using CSS, including viewport meta tags, flexible grids, fluid media, media queries, and relative units. It also covers using CSS Grid and Flexbox together and recommends CSS framework

What does the CSS box-sizing property do?What does the CSS box-sizing property do?Apr 30, 2025 pm 03:18 PM

The article discusses the CSS box-sizing property, which controls how element dimensions are calculated. It explains values like content-box, border-box, and padding-box, and their impact on layout design and form alignment.

How can we animate using CSS?How can we animate using CSS?Apr 30, 2025 pm 03:17 PM

Article discusses creating animations using CSS, key properties, and combining with JavaScript. Main issue is browser compatibility.

Can we add 3D transformations to our project using CSS?Can we add 3D transformations to our project using CSS?Apr 30, 2025 pm 03:16 PM

Article discusses using CSS for 3D transformations, key properties, browser compatibility, and performance considerations for web projects.(Character count: 159)

How can we add gradients in CSS?How can we add gradients in CSS?Apr 30, 2025 pm 03:15 PM

The article discusses using CSS gradients (linear, radial, repeating) to enhance website visuals, adding depth, focus, and modern aesthetics.

What are pseudo-elements in CSS?What are pseudo-elements in CSS?Apr 30, 2025 pm 03:14 PM

Article discusses pseudo-elements in CSS, their use in enhancing HTML styling, and differences from pseudo-classes. Provides practical examples.

See all articles

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

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment