参考资料 https://www.w3cplus.com/css3/do-you-really-understand-css-linear-gradients.html
渐变背景,都是在chrome下调试,这个样式有兼容性问题,在不同浏览器有差异
语法:
1 | <linear-gradient> = linear-gradient([ [ <angle> | to <side-or-corner> ] ,]? <color-stop>[, <color-stop>]+) |
值:
to left:设置渐变为从右到左。相当于: 270deg
to right:设置渐变从左到右。相当于: 90deg
to top:设置渐变从下到上。相当于: 0deg
to bottom:设置渐变从上到下。相当于: 180deg。这是默认值
,等同于留空不写。
1)不同方向的渐变(top
、right
、bottom
、left
、left top
、top right
、bottom right
或者left bottom
)
1 | <!DOCTYPE html> |
2)起始颜色到结束颜色
1 |
|
起始位置到50%之间白色,50%到70%之间渐变,70%之后红色。
3)实现时间轴效果
1 |
|
记得刚入职不久,为了写这条线,延后沿着它展开布局,费了不少劲。
总结
考虑到浏览器兼容性,写下区别
1 | /* Safari 5.1 - 6.0 */ |