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.
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}
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标签 }
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同级的其他选择器}
Structure pseudo-class selector nth-child(n) :n can be numbers, keywords and formulas
Common keywords even: even number, odd: odd number
Function | |
---|---|
Matches the first child element of the parent element e | |
matches the last e element in the parent element | |
matches the nth child in the parent element Element e | |
Specifies the first element of type e | |
Specifies the last | |
Specifies the nth | # of type e
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
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;
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; 单一属性设置右下角设置
text-shadow text shadow The horizontal shadow, vertical shadow, blur distance and shadow color can be specified through the attribute value
v-shadow | |
blur | |
color | |
文字阴影:水平位置 垂直位置 模糊程度 颜色text-shadow: 10px 20px 5px #f00; Copy after login | Multi-layer shadow: The first written shadow is overlaid on the later written shadow
##h-shadow | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
v-shadow | Required, vertical shadow position | |||||||||||
blur | Blur distance | |||||||||||
##spread | Shadow size | |||||||||||
color | Shadow color | |||||||||||
inset | Outer shadow changed to inner shadow | |||||||||||
边框阴影:水平位置 垂直位置 模糊程度 拓展大小 颜色 是否内边框阴影box-shadow: 20px 20px 5px 20px #f00 inset; Copy after login 过渡属性transition
transition-property过渡的属性 .box{ width: 100px; height: 100px; background-color: aquamarine; transition: all 2s linear 0s; 过渡属性的使用(动画效果) } .box:hover{ width: 500px; } Copy after login 2D转换-transform transform: translate(10px,10px); Copy after login 缩放scale() transform: rotate(30deg); Copy after login 倾斜skew() transform-origin: left top; 以左上角为基准点 Copy after login 3D转换 transform-style: preserve-3d; Copy after login 浏览器兼容 动画 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!
Related labels:
source:php.cn
Previous article:What is the difference between CSS Holy Grail layout and Double Flying Wing layout?
Next article:what is css after
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
Make the page mobile-friendly?
I have many web pages and some websites. The thing is, I'm a beginner. I'm using basic htm...
From 2024-04-01 20:42:38
0
1
259
Related Topics
More>
|