用css3属性写进度条

1.linear-gradient基础:

[html]  view plain  copy
  1. <!DOCTYPE html>  
  2. <html lang="en">  
  3. <head>  
  4.     <meta charset="UTF-8">  
  5.     <title></title>  
  6.     <style type="text/css">  
  7.         .box {  
  8.             margin: 200px 0 0 200px;  
  9.             width: 200px;  
  10.             height: 200px;  
  11.             background-color: orange;  
  12.   
  13.             /*基本用法*/  
  14.             background-image: linear-gradient(red, yellow, blue, green);  
  15.             background-image: linear-gradient(rgba(255, 0, 0, .2), yellow, blue, green);  
  16.   
  17.             /*控制颜色渐变的方向  
  18.   
  19.                 to right -- 从左向右  
  20.                 to top -- 从下到上  
  21.                 to left -- 从右到左  
  22.                 to bottom --- 从上到下(默认值)  
  23.   
  24.             */  
  25.             background-image: linear-gradient(to right, red, yellow, blue, green);  
  26.             background-image: linear-gradient(to top, red, yellow, blue, green);  
  27.             background-image: linear-gradient(to left, red, yellow, blue, green);  
  28.             background-image: linear-gradient(to bottom, red, yellow, blue, green);  
  29.   
  30.   
  31.             /*0deg = to top -- 从下到上*/  
  32.             background-image: linear-gradient(0deg, red, yellow, blue, green);  
  33.             /*基于0度顺时针旋转45deg*/  
  34.             background-image: linear-gradient(45deg, red, yellow, blue, green);  
  35.             /*基于0度逆时针旋转45deg*/  
  36.             background-image: linear-gradient(-45deg, red, yellow, blue, green);  
  37.   
  38.   
  39.             /*设置过渡颜色的起始位置*/  
  40.             /*从过渡起始位置50px开始让红色和黄色之间产生颜色渐变效果*/  
  41.             background-image: linear-gradient(to right, red 50px, yellow, blue, green);  
  42.             background-image: linear-gradient(to right, red 50px, yellow 50px, blue, green);  
  43.             background-image: linear-gradient(to right, red 50px, yellow 50px, yellow 100px, blue, green);  
  44.   
  45.   
  46.   
  47.         }  
  48.   
  49.         .box:hover {  
  50.   
  51.         }  
  52.     </style>  
  53. </head>  
  54. <body>  
  55.   
  56. <div class="box"></div>  
  57.   
  58. <script type="text/javascript">  
  59. </script>  
  60. </body>  
  61. </html>  

2.重复线性渐变:repeating-linear-gradient

[html]  view plain  copy
  1. <!DOCTYPE html>  
  2. <html lang="en">  
  3. <head>  
  4.     <meta charset="UTF-8">  
  5.     <title></title>  
  6.     <style type="text/css">  
  7.         .box {  
  8.             margin: 200px 0 0 200px;  
  9.             width: 1200px;  
  10.             height: 200px;  
  11.             background-color: orange;  
  12.       
  13.             background-image: linear-gradient(to right  
  14.             , red 0  
  15.             , red 50px  
  16.             , yellow 50px  
  17.             , yellow 100px  
  18.             , red 100px  
  19.             , red 150px  
  20.             , yellow 150px  
  21.             , yellow 200px);  
  22.             /**与上面重复写渐变有相同的效果*/  
  23.             background-image: repeating-linear-gradient(  
  24.                     to right  
  25.                     , red 0  
  26.                     , red 50px  
  27.                     , yellow 50px  
  28.                     , yellow 100px  
  29.             );  
  30.   
  31.   
  32.   
  33.         }  
  34.   
  35.         .box:hover {  
  36.   
  37.         }  
  38.     </style>  
  39. </head>  
  40. <body>  
  41.   
  42. <div class="box"></div>  
  43.   
  44. <script type="text/javascript">  
  45. </script>  
  46. </body>  
  47. </html>  

3.记事本制作:

[html]  view plain  copy
  1. <!DOCTYPE html>  
  2. <html lang="en">  
  3. <head>  
  4.     <meta charset="UTF-8">  
  5.     <title></title>  
  6.     <style type="text/css">  
  7.         .box {  
  8.             margin: 0 auto;  
  9.             width: 800px;  
  10.             height: 500px;  
  11.             background-color: orange;  
  12.             border: 1px solid;  
  13.   
  14.             background-image: repeating-linear-gradient(  
  15.                      #fff 0  
  16.                     , #fff 50px  
  17.                     , #999 50px  
  18.                     , #999 51px  
  19.             );  
  20.         }  
  21.   
  22.         .box:hover {  
  23.   
  24.         }  
  25.     </style>  
  26. </head>  
  27. <body>  
  28.   
  29. <div class="box"></div>  
  30.   
  31. <script type="text/javascript">  
  32. </script>  
  33. </body>  
  34. </html>  
效果:

4.帆布背景制作:

[html]  view plain  copy
  1. <!DOCTYPE html>  
  2. <html lang="en">  
  3. <head>  
  4.     <meta charset="UTF-8">  
  5.     <title></title>  
  6.     <style type="text/css">  
  7.         .box {  
  8.             margin: 0 auto;  
  9.             width: 800px;  
  10.             height: 500px;  
  11.             /*background-color: orange;*/  
  12.             border: 1px solid;  
  13.   
  14.             background-image: repeating-linear-gradient(  
  15.                      rgba(255, 0, 0, .3) 0  
  16.                     ,  rgba(255, 0, 0, .3) 20px  
  17.                     , rgba(255, 255, 0, .3)  20px  
  18.                     , rgba(255, 255, 0, .3)  40px  
  19.             ), repeating-linear-gradient( to right,  
  20.                     rgba(255, 0, 0, .3) 0  
  21.                     ,  rgba(255, 0, 0, .3) 20px  
  22.                     , rgba(255, 255, 0, .3)  20px  
  23.                     , rgba(255, 255, 0, .3)  40px  
  24.             );  
  25.   
  26.   
  27.             background-image: repeating-linear-gradient(45deg,  
  28.                     rgba(255, 0, 0, .3) 0  
  29.                     ,  rgba(255, 0, 0, .3) 20px  
  30.                     , rgba(255, 255, 0, .3)  20px  
  31.                     , rgba(255, 255, 0, .3)  40px  
  32.             ), repeating-linear-gradient( -45deg,  
  33.                     rgba(255, 0, 0, .3) 0  
  34.                     ,  rgba(255, 0, 0, .3) 20px  
  35.                     , rgba(255, 255, 0, .3)  20px  
  36.                     , rgba(255, 255, 0, .3)  40px  
  37.             );  
  38.   
  39.   
  40.   
  41.         }  
  42.   
  43.         .box:hover {  
  44.   
  45.         }  
  46.     </style>  
  47. </head>  
  48. <body>  
  49.   
  50. <div class="box"></div>  
  51.   
  52. <script type="text/javascript">  
  53. </script>  
  54. </body>  
  55. </html>  

效果如下:


5.进度条效果:原理重复线性渐变,移动背景图.

[html]  view plain  copy
  1. <!DOCTYPE html>  
  2. <html lang="en">  
  3. <head>  
  4.     <meta charset="UTF-8">  
  5.     <title></title>  
  6.     <style type="text/css">  
  7.         .box {  
  8.             margin: 100px 0 0 100px;  
  9.             width: 800px;  
  10.             height: 80px;  
  11.   
  12.             /*渐变图形的大小*/  
  13.             background-image: repeating-linear-gradient(  
  14.                 45deg,  
  15.                 green 0px,  
  16.                 green 10px,  
  17.                 #fff 10px,  
  18.                 #fff 20px  
  19.             );  
  20.   
  21.             background-size: 12000px 80px;  
  22.         }  
  23.   
  24.         /*鼠标悬浮,改变背景图位置*/  
  25.         .box:hover{  
  26.             background-position: -500px 0;  
  27.             transition: 10s;  
  28.         }  
  29.   
  30.   
  31.     </style>  
  32. </head>  
  33. <body>  
  34.   
  35. <div class="box"></div>  
  36.   
  37. <script type="text/javascript">  
  38. </script>  
  39. </body>  
  40. </html>  

效果:



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值