css 的三大特性?
1,层叠性 (一个标签可以有多个css样式)
2,继承性 (子标签能继承父标签的某些样式, 比如文本颜色和字号,但是有些样式不能继承)
3,优先级
css权重公式?
继承 * 0 0 0 0
标签 0 0 0 1
类 伪类 0 0 1 0
id 0 1 0 0
行内 1 0 0 0
!important 无穷
width height 大于无穷大
div ul li - 0 0 0 3
li - 0 0 0 1
贡献值没有进位 权重不能继承
常用的单位 ?
px (像素)
em (绝对单位 , 如果父级的字号是16px , 可以设置为 2 em ,就是 32px)
rem (由整个html的字号决定,改变浏览器的字号设置,页面的字号也发生变化)
百分比 相对父元素的比例
行内元素没有宽和高
浏览器加的margin为8px
文档流:
在网页中将窗体自上而下分成好多行,在每行从左到右的顺序排列元素,是网页默认的布局方式
定位 position
static 文档流 默认的
absolute 相对于一个父元素的绝对定位
当设置了定位之后,原来的元素会脱离文档流,会在页面上浮起来
relative 相对定位
相对于他的上一个元素定位
fixed 固定定位
导航栏 固定定位
子绝父相 子元素绝对定位 父元素相对定位
- html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Documenttitle>
- <style>
- /* transition
- 过渡转变 transition-duration 是必须写的
-
- */
- div{
- width: 300px;
- height: 300px;
- background-color: red;
-
- /* transition-property: all;
- transition-duration: 3s;
- transition-timing-function:ease-in-out; */
-
- animation: myAnim 5s;
- }
- /* div:hover {
- width: 500px;
- height: 500px;
- background-color:aqua;
- } */
-
-
- @keyframes myAnim{
-
- 0%{
- background-color: red;
- }
- 50%{
- background-color: green;
- }
- 100%{
- background-color: black;
- }
- }
- style>
- head>
- <body>
- <div >div>
- body>
- html>