HTML5基础加强css样式篇(background-image线性渐变函数:linear-gradient)(四十)
来源:互联网 发布:淘宝卖家如何修改价格 编辑:程序博客网 时间:2024/04/28 01:39
1.linear-gradient基础:
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .box { margin: 200px 0 0 200px; width: 200px; height: 200px; background-color: orange; /*基本用法*/ background-image: linear-gradient(red, yellow, blue, green); background-image: linear-gradient(rgba(255, 0, 0, .2), yellow, blue, green); /*控制颜色渐变的方向 to right -- 从左向右 to top -- 从下到上 to left -- 从右到左 to bottom --- 从上到下(默认值) */ background-image: linear-gradient(to right, red, yellow, blue, green); background-image: linear-gradient(to top, red, yellow, blue, green); background-image: linear-gradient(to left, red, yellow, blue, green); background-image: linear-gradient(to bottom, red, yellow, blue, green); /*0deg = to top -- 从下到上*/ background-image: linear-gradient(0deg, red, yellow, blue, green); /*基于0度顺时针旋转45deg*/ background-image: linear-gradient(45deg, red, yellow, blue, green); /*基于0度逆时针旋转45deg*/ background-image: linear-gradient(-45deg, red, yellow, blue, green); /*设置过渡颜色的起始位置*/ /*从过渡起始位置50px开始让红色和黄色之间产生颜色渐变效果*/ background-image: linear-gradient(to right, red 50px, yellow, blue, green); background-image: linear-gradient(to right, red 50px, yellow 50px, blue, green); background-image: linear-gradient(to right, red 50px, yellow 50px, yellow 100px, blue, green); } .box:hover { } </style></head><body><div class="box"></div><script type="text/javascript"></script></body></html>
2.重复线性渐变:repeating-linear-gradient
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .box { margin: 200px 0 0 200px; width: 1200px; height: 200px; background-color: orange; background-image: linear-gradient(to right , red 0 , red 50px , yellow 50px , yellow 100px , red 100px , red 150px , yellow 150px , yellow 200px); /**与上面重复写渐变有相同的效果*/ background-image: repeating-linear-gradient( to right , red 0 , red 50px , yellow 50px , yellow 100px ); } .box:hover { } </style></head><body><div class="box"></div><script type="text/javascript"></script></body></html>
3.记事本制作:
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .box { margin: 0 auto; width: 800px; height: 500px; background-color: orange; border: 1px solid; background-image: repeating-linear-gradient( #fff 0 , #fff 50px , #999 50px , #999 51px ); } .box:hover { } </style></head><body><div class="box"></div><script type="text/javascript"></script></body></html>效果:
4.帆布背景制作:
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .box { margin: 0 auto; width: 800px; height: 500px; /*background-color: orange;*/ border: 1px solid; background-image: repeating-linear-gradient( rgba(255, 0, 0, .3) 0 , rgba(255, 0, 0, .3) 20px , rgba(255, 255, 0, .3) 20px , rgba(255, 255, 0, .3) 40px ), repeating-linear-gradient( to right, rgba(255, 0, 0, .3) 0 , rgba(255, 0, 0, .3) 20px , rgba(255, 255, 0, .3) 20px , rgba(255, 255, 0, .3) 40px ); background-image: repeating-linear-gradient(45deg, rgba(255, 0, 0, .3) 0 , rgba(255, 0, 0, .3) 20px , rgba(255, 255, 0, .3) 20px , rgba(255, 255, 0, .3) 40px ), repeating-linear-gradient( -45deg, rgba(255, 0, 0, .3) 0 , rgba(255, 0, 0, .3) 20px , rgba(255, 255, 0, .3) 20px , rgba(255, 255, 0, .3) 40px ); } .box:hover { } </style></head><body><div class="box"></div><script type="text/javascript"></script></body></html>
效果如下:
5.进度条效果:原理重复线性渐变,移动背景图.
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .box { margin: 100px 0 0 100px; width: 800px; height: 80px; /*渐变图形的大小*/ background-image: repeating-linear-gradient( 45deg, green 0px, green 10px, #fff 10px, #fff 20px ); background-size: 12000px 80px; } /*鼠标悬浮,改变背景图位置*/ .box:hover{ background-position: -500px 0; transition: 10s; } </style></head><body><div class="box"></div><script type="text/javascript"></script></body></html>
效果:
0 0
- HTML5基础加强css样式篇(background-image线性渐变函数:linear-gradient)(四十)
- HTML5基础加强css样式篇(background-image径向渐变函数)(四十一)
- HTML5基础加强css样式篇(css计算函数:calc())(四十七)
- html5用css3实现线性渐变background-image:linear-gradient使用方法
- 线性渐变(linear-gradient)
- HTML5基础加强css样式篇(white-space属性)(四十三)
- HTML5基础加强css样式篇(文本裁剪,背景裁剪:background-origin,background-position,background-clip)(三十七)
- CSS3线性渐变 径向渐变 background linear-gradient radial-gradient
- HTML5基础加强css样式篇(背景图大小设置:background-size)(三十九)
- CSS3 线性渐变(linear-gradient)
- CSS3 线性渐变(linear-gradient)
- CSS3 线性渐变(linear-gradient)
- CSS3线性渐变(linear-gradient)
- CSS3 线性渐变(linear-gradient)
- CSS3 线性渐变(linear-gradient)
- CSS3线性渐变(linear-gradient)
- css3线性渐变(linear-gradient)
- CSS3的线性渐变(linear-gradient)
- 剑指offer40:数组中只出现一次的数字
- mysql查询今天、昨天、7天、近30天、本月、上一月 数据
- java内存,堆,栈,方法区
- c++作业四
- 文章标题
- HTML5基础加强css样式篇(background-image线性渐变函数:linear-gradient)(四十)
- Friends (暴力枚举)
- Android手机UI设计---”知乎“界面外观模仿篇(三)---ScrollView的使用
- Oracle常见操作
- php实现屏蔽关键字
- js常用正则表达式
- linux 查看网卡流量方法
- matlab 文件读取函数dir,以及生产的相应结构体 细节
- get 和 post的差距