css的过渡与渐变

渐变:
一、线性渐变:
从一个方向到另一个方向的颜色的变化。
标准模式的语法(不添加浏览器前缀):
background: linear-gradient(direction, color-stop1, color-stop2, …);
说明:
direction:默认为to bottom,即从上向下的渐变;
stop:颜色的分布位置,默认均匀分布,例如有3个颜色,各个颜色的stop均为33.33%。
兼容模式语法(添加浏览器前缀):
background:linear-gradient( direction, color-stop1, color-stop2,。。。)
说明: direction: 不能添加to 默认指的是 从哪个方向开始
渐变方向:
1:to left \ to right \ to top
2: 对角着渐变
to left top \ to right bottom
3: 渐变线角度的变化
例如:标准模式 : 40deg 40度
兼容模式 : 90 - 40
线性渐变:颜色的分布:
linear-gradient(方向, 颜色1 20%,颜色2 30%,颜色3 )
到20%这个位置仍然是颜色1 出了20% 开始向颜色2渐变
二、径向渐变:
从一个点到四周的颜色的过渡变化。
语法:(必须加浏览器前缀)
background: radial-gradient(center, shape, size, start-color, …, last-color);
说明:
center:渐变起点的位置,可以为百分比,默认是图形的正中心。
shape:渐变的形状,ellipse表示椭圆形,circle表示圆形。默认为ellipse,如果元素形状为正方形的元素,则ellipse和circle显示一样。
size:渐变的大小,即渐变到哪里停止,它有四个值。 closest-side:最近边; farthest-side:最远边; closest-corner:最近角; farthest-corner:最远角。
关于径向渐变的大小:
closest-side 最近边
farthest-side 最远边
closest-corner 最近角
farthest-corner 最远角

 三、重复性渐变:
语法:background:-webkit-repeating-radial-gradient(#dd0,pink 5%,#000 10%)
       重复性线性渐变
        background:repeating-linear-gradient();
       重复性径向渐变
        background:repeating-radial-gradient();

过渡:
1. transition-property:检索或设置对象中的参与过渡的属性
2. transition-duration:检索或设置对象过渡的持续时间
3. transition-delay:检索或设置对象延迟过渡的时间
4. transition-timing-function:检索或设置对象中过渡的动画类型
动画的运动类型:
默认的不是匀速 ,默认的是ease(逐渐减慢)
简写属性:
transition:过渡的属性(all) 过渡的时间 延迟时间 动画的类型(linear 匀速)
注:transition 必须通过事件触发!(鼠标滑过)改变css属性的值。

发布了21 篇原创文章 · 获赞 0 · 访问量 209

猜你喜欢

转载自blog.csdn.net/weixin_46579411/article/details/105301749