Home Web Front-end CSS Tutorial What's new in css3

What's new in css3

Dec 03, 2020 am 10:50 AM
css3

The new contents of css3 include: 1. Child selector, used to select elements with a specific parent element; 2. Sibling selector, used to select sibling elements immediately after another element; 3. Other sibling selectors; 4. Structural pseudo-class selectors; 5. Pseudo-element selectors, etc.

What's new in css3

The operating environment of this article: windows7 system, css3 version, DELL G3 computer.

New content in CSS3:

##New content in CSS3 Selector
Child selector Child selector is used to select elements with a specific parent element

.box > p{
  background-color: pink}
Copy after login

Sibling selector Adjacent sibling selector: used to select sibling elements immediately following another element, and both have the same parent element

h1 + p{
  margin-top:50px;    满足h1相邻的p标签  }
Copy after login

Other sibling selectors Match all element2 elements after element1 in the same parent element. The two elements are the same parent element

h2 ~ p{
  background: ff0000;   和h2同级的其他选择器}
Copy after login

Structure pseudo-class selector nth-child(n) :n can be numbers, keywords and formulas
Common keywords even: even number, odd: odd number

SelectorFunctione:first-child Matches the first child element of the parent element ee: last-childmatches the last e element in the parent elemente:nth-child(n)matches the nth child in the parent element Element e##e:first-of-typee:last-of -typee of type e:last-of-type# of type e ##Pseudo element selector
Specifies the first element of type e
Specifies the last
Specifies the nth

Add a new pseudo element, the browser can recognize both single colon and double colon, and double colon is the h5 grammar specification Pseudo elements can only be added to double tags The attribute content:"";
must be written in the pseudo element. There cannot be a space before the colon of the pseudo element
before and after create an element, which is an inline element


SelectorFunction##e::beforein Insert an element before the E element Insert an element after the E element The first letter in the E container is selectedThe E container is selected The first line of text withinAttribute selector
e::after
e:first-letter
e::first-line
 input[name]{  选择input中带有name属性的选择器    width:30px;
    height:30px;
  }
  input[type="checkbox"]{  选择input中type="checkbox"属性的选择器    width:30px;
    height:30px;
  }
  input[type^="check"]{  包含input中type="check"开头属性的选择器    width:30px;
    height:30px;
  }
  input[class&="check"]{  包含input中class="box"结尾属性的选择器    width:30px;
    height:30px;
  }
   input[class*="eck"]{  包含input中含有class="eck"属性的选择器    width:30px;
    height:30px;
Copy after login

New selector weight

The weight of pseudo-class selectors and attribute selectors is equal to the class selector

The weight of pseudo-element selectors is equal to the label selector CSS3 box model

css3 can be achieved through box-sizing Specify the box model so that we can set how to calculate the total width and total height of an element
content-box standard mode
The total size of the box is width padding border, and the content area is width and height Part
border-box weird mode
The box size is width and height, add padding and border, the content area will shrink
Border fillet border-radius Set the circle of the border Angular

border-radius: 100px/50px   分别设置水平方向和垂直方向半径border-bottom-right-radius: 50px; 单一属性设置右下角设置
Copy after login


text-shadow text shadow

The horizontal shadow, vertical shadow, blur distance and shadow color can be specified through attribute values

text-shadow text shadow The horizontal shadow, vertical shadow, blur distance and shadow color can be specified through the attribute value


Attribute valueFunctionh-shadowRequired, horizontal shadow positionRequired, vertical shadow positionBlur distanceShadow colorMulti-layer shadow: The first written shadow is overlaid on the later written shadow
v-shadow
blur
color
文字阴影:水平位置 垂直位置 模糊程度 颜色text-shadow: 10px 20px 5px #f00;
Copy after login
box-shadow box shadow

Used to add shadow to the box border


Attribute valueFunction##h-shadowRequired, horizontal shadow positionv-shadowRequired, vertical shadow positionblurBlur distance
##spreadShadow size
colorShadow color
insetOuter shadow changed to inner shadow
边框阴影:水平位置 垂直位置 模糊程度 拓展大小 颜色 是否内边框阴影box-shadow: 20px 20px 5px 20px #f00 inset;
Copy after login

过渡属性transition
transition: 过渡属性 过渡时间 运动曲线 延时时间;

属性值作用
transition简写属性,用于在一个属性中设置其他4个过渡属性
transition-property规定应用过渡的css属性的名称
transition-duration定义过渡效果花费的时间,默认是0
transition-timing-function规定过渡效果的时间曲线,默认是ease
transition-delay规定过渡效果何时开始。默认是0

transition-property过渡的属性
none表示没有属性过渡
all表示所有变化的属性都过渡
属性名:使用具体的属性名,多个属性名之间逗号分隔
transition-timing-function 时间曲线
Whats new in css3

.box{
    width: 100px;
    height: 100px;
    background-color: aquamarine;
    transition: all 2s linear 0s;     过渡属性的使用(动画效果)  }
  .box:hover{
    width: 500px;
  }
Copy after login

2D转换-transform
移动translate()

作用:对元素进行移动、缩放、转动、拉长、拉伸,配合过渡效果实现动画效果
Whats new in css3

transform: translate(10px,10px);
Copy after login

缩放scale()
transform的属性值为scale()可以实现缩放效果
scale为1以上为放大效果,为0到1之间缩放
Whats new in css3
旋转rotate()
实现元素旋转
元素旋转后,坐标轴也会发生改变
正数表示顺时针旋转,负数表示逆时针旋转

transform: rotate(30deg);
Copy after login

倾斜skew()
设置skew(),实现元素倾斜
书写语法:transform:skew(数字deg,数字deg);
transform-origin 属性
设置调整元素的水平和垂直方向原点位置,调整元素基准点
x:定义X轴的原点,可能的值:left、center、right、像素值、百分比
y:定义y轴的原点,可能的值:left、center、right、像素值、百分比

transform-origin: left top;   以左上角为基准点
Copy after login

3D转换
透视perspective
透视可以将一个2D平面在转换过程中呈现3D效果
作用:设置在Z轴的视线焦点的观察位置,从而实现3D效果
属性值:像素值,数值越大,观察点距离z轴原点越远
3D旋转
Whats new in css3
3D位移
加粗样式属性值为像素或者百分比
Whats new in css3
transform-style属性
用于设置被嵌套的子元素在父元素的3D空间中显示,子元素会保留自己的3D转换坐标轴
属性值:flat:所有子元素在2D平面呈现,preserve-3d:保留3D空间

transform-style: preserve-3d;
Copy after login

浏览器兼容
internet Explorer10、Firefox以及Opera支持transform属性
Chrome 和 Safari需要前缀-webkit-
internet Explorer9 需要前缀-ms-

动画
css3中提供了自己的动画制作方法
css3动画制作分为两步,创建动画、制作动画

animation属性
需要将@keyframes中创建的动画捆绑到某个选择器,否则不会产生动画效果
animation属性用于对动画进行捆绑
语法:animation:动画名称 过渡时间 速度曲线 动画次数 延时时间

小球运动动画代码

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    .box{
      width: 100px;
      height: 100px;
      border-radius: 50%;
      margin: 200px auto;
      background-color: skyblue;
      /* 添加绑定动画 */
      animation: move1 2s linear infinite;
    }
    /* 开头和结尾定义动画效果 */
    @keyframes move{
      from{
        transform: translateY(0);
      }
      to{
        transform: translateY(150px);
      }
    }
    @keyframes move1{
      0%{
        transform: translateY(0);
      }
      25%{
        transform: translateY(200px);
      }
      50%{
        transform: translateY(0);
      }
      75%{
        transform: translateY(-200px);
      }
      100%{
        transform: translateY(0);
      }
    }
  </style>
</head>
<body>
  <p class="box">
  </p>
</body>
</html>
Copy after login

               

The above is the detailed content of What's new in 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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

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 hide elements in css without taking up space How to hide elements in css without taking up space Jun 01, 2022 pm 07:15 PM

Two methods: 1. Using the display attribute, just add the "display:none;" style to the element. 2. Use the position and top attributes to set the absolute positioning of the element to hide the element. Just add the "position:absolute;top:-9999px;" style to the element.

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!

How to enlarge the image by clicking the mouse in css3 How to enlarge the image by clicking the mouse in css3 Apr 25, 2022 pm 04:52 PM

Implementation method: 1. Use the ":active" selector to select the state of the mouse click on the picture; 2. Use the transform attribute and scale() function to achieve the picture magnification effect, the syntax "img:active {transform: scale(x-axis magnification, y Axis magnification);}".

How to set animation rotation speed in css3 How to set animation rotation speed in css3 Apr 28, 2022 pm 04:32 PM

In CSS3, you can use the "animation-timing-function" attribute to set the animation rotation speed. This attribute is used to specify how the animation will complete a cycle and set the speed curve of the animation. The syntax is "element {animation-timing-function: speed attribute value;}".

Does css3 animation effect have deformation? Does css3 animation effect have deformation? Apr 28, 2022 pm 02:20 PM

The animation effect in css3 has deformation; you can use "animation: animation attribute @keyframes ..{..{transform: transformation attribute}}" to achieve deformation animation effect. The animation attribute is used to set the animation style, and the transform attribute is used to set the deformation style. .

See all articles