Home Web Front-end CSS Tutorial What new attribute styles are added to css3? Introduction to commonly used new features of css3

What new attribute styles are added to css3? Introduction to commonly used new features of css3

Oct 08, 2018 am 11:04 AM
css3 new features

What are the new attribute styles (new features) of css3? This chapter will focus on introducing several new attribute styles (new features) commonly used in CSS3. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Before introducing the new attribute styles (new features) of CSS3, we must first know what CSS3 is.

CSS is the abbreviation of Cascading Style Sheets.
CSS is a markup language that is a browser interpreted language and can be executed directly by the browser without compilation.
CSS is a markup language used to represent HTML or XML.
CSS is recommended and maintained by the W3C CSS Working Group.
CSS is a required course for beginners in programming. Using CSS styles can make the page beautiful.
CSS syntax consists of three parts: selector, property and value, for example: selector {property: value}.

CSS3 is the latest CSS standard. It adds some new attribute styles, which are new features. Below we will introduce several commonly used new features (attribute styles) in css3:

1. Border

border-image Attribute : It is a shorthand attribute, used to set the shorthand attribute of all border-image-* attributes.

border-radius attribute: It is a shorthand attribute used to set four border-*-radius attributes.

border-top-left-radius Set the upper left corner
border-top-right-radius Set the upper right corner
border-bottom-right-radius Set the lower left corner
border-bottom-right -radius Set the lower right corner
border-top-left-radius: x y; x represents the x-axis offset of the upper left corner, y represents the y-axis offset, and you can set percentages and pixels.

border-radius:;
One value represents upper left, upper right, lower left and lower right, all are
Two values ​​represent the first value upper left and lower right The second value represents upper right and lower left
The three values ​​represent: the first one is upper left, the second value is upper right and lower left, the third value is lower right
, the four are respectively upper left, upper right, lower right and lower left.

border-radius 0 0 0 0/ 0 0 0 0;
The first four are the x-axis offsets in the four x-directions and the last four are the offsets in the y-axis direction

box-shadow property: Add one or more shadows to the box.

Syntax: box-shadow: value
Value description:
(1) The first value: Npx, the shadow is offset by N pixels in the horizontal direction, positive numbers go to the right, negative numbers go to the left
(2) The second value: Npx, the shadow is offset by N pixels in the vertical direction, positive numbers go down, negative numbers go up
(3) The third value: feather size (blurred size)
(4) The fourth value: shadow size
(5) The fifth value: color. The default value is black
(6) The sixth parameter: inner and outer shadow. The default is outer shadow. The inner shadow is inset
. (7) You can write multiple shadows, separated by commas
(8) The shadow can be abbreviated, but it should be noted that some values ​​need to be filled with 0

Comprehensive example:

p{
    border: 2px solid red;
    border-radius:25px; /* 创建圆角,100%为圆形 */
    box-shadow: 10px 10px 5px #888888;
}
Copy after login

2. Background

background-size attribute: Specifies the size of the background image. (Important attributes)

Syntax: background-size: value

Value description:
(1) When there is only one value, the width is stretched, and the height will remain proportional. It can support px or percentage. The percentage refers to the width and height of the box itself
(2) When there are two values, the width and height will be stretched to the corresponding values ​​respectively, and may be deformed. It can support px or percentage. The percentage refers to the width and height of the box itself
(3) contain When the width or height of the image "touches" the edge of the box when scaling, the change will stop (width or height only need to satisfy one)
(4) On the basis of contain, ensure that there is no blank space. This is the effect of cover (both width and height need to be satisfied)

background-origin attribute: Specifies the positioning area of ​​the background image.

Syntax: background-origin: value

Value description:
(1) border-box: Ignore the border and tile directly from the starting point 0 of the border, 0 point
(2) padding-box: Default value, ignore padding and tile directly from the starting point of padding 0, 0 point
(3) content-box: Tiling starts from the content part and is related to padding

background-image attribute: Sets the background image of the element.

background-repeat attribute: Set whether and how to repeat the background image.

3. Text effect

text-align-last attribute: Set how to align the last line or the line immediately before the forced line break .

text-emphasis属性:向元素的文本应用重点标记以及重点标记的前景色。

text-justify属性:规定当 text-align,设置为“justify”时所使用的对齐方法。

text-outline属性:规定文本的轮廓。

text-overflow属性:规定当文本溢出包含元素时发生的事情。

text-shadow属性:向文本添加阴影。

text-wrap属性:规定文本的换行规则。

word-wrap属性:允许对长的不可分割的单词进行分割并换行到下一行。

四、颜色与透明度

rgba()

R:Red、G:Green、B:Blue、A:Alpha,R、G、B 取值范围0~255,A的取值范围是0-1。

RGBA可以用于所有使用颜色的地方
rgb三个值越小,颜色越黑
如果是纯色的背景,可以是使用rgba
如果是图片,可以脱离父子关系,让后用定位的方式来做。

hsla()

H 色调 取值范围0~360,0/360表示红色、120表示绿色、240表示蓝色
S 饱和度取值范围0%~100%
L 亮度 取值范围0%~100%
A 透明度取值范围0~1

例:

background-color: hsla(120,100%,50%,1);
Copy after login

总结:以上就是本篇文的全部内容,希望能对大家的学习有所帮助。

The above is the detailed content of What new attribute styles are added to css3? Introduction to commonly used new features of css3. 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)

How to achieve wave effect with pure CSS3? (code example) How to achieve wave effect with pure CSS3? (code example) Jun 28, 2022 pm 01:39 PM

How to achieve wave effect with pure CSS3? This article will introduce to you how to use SVG and CSS animation to create wave effects. I hope it will be helpful to you!

Use CSS skillfully to realize various strange-shaped buttons (with code) Use CSS skillfully to realize various strange-shaped buttons (with code) Jul 19, 2022 am 11:28 AM

This article will show you how to use CSS to easily realize various weird-shaped buttons that appear frequently. I hope it will be helpful to you!

How to implement lace borders in css3 How to implement lace borders in css3 Sep 16, 2022 pm 07:11 PM

In CSS, you can use the border-image attribute to achieve a lace border. The border-image attribute can use images to create borders, that is, add a background image to the border. You only need to specify the background image as a lace style; the syntax "border-image: url (image path) offsets the image border width inward. Whether outset is repeated;".

It turns out that text carousel and image carousel can also be realized using pure CSS! It turns out that text carousel and image carousel can also be realized using pure CSS! Jun 10, 2022 pm 01:00 PM

How to create text carousel and image carousel? The first thing everyone thinks of is whether to use js. In fact, text carousel and image carousel can also be realized using pure CSS. Let’s take a look at the implementation method. I hope it will be helpful to everyone!

PHP 8.3 released: new features at a glance PHP 8.3 released: new features at a glance Nov 27, 2023 pm 12:52 PM

PHP8.3 released: Overview of new features As technology continues to develop and needs change, programming languages ​​are constantly updated and improved. As a scripting language widely used in web development, PHP has been constantly improving to provide developers with more powerful and efficient tools. The recently released PHP 8.3 version brings many long-awaited new features and improvements. Let’s take a look at an overview of these new features. Initialization of non-null properties In past versions of PHP, if a class property was not explicitly assigned a value, its value

A guide to learn the new features of PHP8 and gain an in-depth understanding of the latest technology A guide to learn the new features of PHP8 and gain an in-depth understanding of the latest technology Dec 23, 2023 pm 01:16 PM

An in-depth analysis of the new features of PHP8 to help you master the latest technology. As time goes by, the PHP programming language has been constantly evolving and improving. The recently released PHP8 version provides developers with many exciting new features and improvements, bringing more convenience and efficiency to our development work. In this article, we will analyze the new features of PHP8 in depth and provide specific code examples to help you better master these latest technologies. JIT compiler PHP8 introduces JIT (Just-In-Time) compilation

Cleverly use CSS3 filters to create text flash switching animation effects! Cleverly use CSS3 filters to create text flash switching animation effects! Jul 20, 2022 am 10:55 AM

This article will show you how to use CSS3 filters to achieve a high-end text flash switching animation effect. I hope it will be helpful to you!

What are the new features of php8 What are the new features of php8 Sep 25, 2023 pm 01:34 PM

New features of php8 include JIT compiler, type deduction, named parameters, union types, properties, error handling improvements, asynchronous programming support, new standard library functions and anonymous class extensions. Detailed introduction: 1. JIT compiler, PHP8 introduces the JIT compiler, which is an important performance improvement. The JIT compiler can compile and optimize some high-frequency execution codes in real time, thereby improving the running speed; 2. Type derivation , PHP8 introduces the type inference function, allowing developers to automatically deduce the type of variables when declaring variables, etc.

See all articles