css3 Gradients 线性渐变

简介:

代码块

html页面:

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<title>css3 Gradients</title>

</head>

<body>

<div class="grad-repeating-lg">重复的线性渐变</div>


<div class="grad-rgba-0-1">从左边开始的线性渐变。起点是完全透明,慢慢过渡到完全不透明的红色</div>

<div class="grad-r-o-y-g-b-i-v">带有彩虹颜色和文本的线性渐变</div>

<div class="grad-red-green-blue">带有多个颜色结点的从上到下的线性渐变</div>

<div class="grad-45-deg">45角度的线性渐变</div>

<div class="grad-0-deg">0角度的线性渐变</div>

<div class="grad-90-deg">90角度的线性渐变</div>

<div class="grad-180-deg">180角度的线性渐变</div>

<div class="grad-FF69B4-2F4F4F">从右上角开始(到左下角)的线性渐变</div>

<div class="grad-008B8B-DEB887">从左上角开始(到右下角)的线性渐变</div>

<div class="grad-A52A2A-6495ED">从左边开始的线性渐变。起点是#A52A2A,慢慢过渡到#6495ED</div>

<div class="grad-red-blue">从顶部开始的线性渐变。起点是红色,慢慢过渡到蓝色</div>

</body>

</html>

css样式:

<style type="text/css" media="screen">

div{

width: 800px;

height: 600px;

padding: 20px;

margin:50px;

}


.grad-red-blue{

background:-webkit-linear-gradient(red,blue);

background:-o-linear-gradient(red,blue);

background:-moz-linear-gradient(red,blue);

background:linear-gradient(red,blue);

}


.grad-A52A2A-6495ED{

background:-webkit-linear-gradient(left,#A52A2A,#6495ED);

background:-o-linear-gradient(right,#A52A2A,#6495ED);

background:-moz-linear-gradient(right,#A52A2A,#6495ED);

background:linear-gradient(to right,#A52A2A,#6495ED);

}


.grad-008B8B-DEB887{

background:-webkit-linear-gradient(left top,#008B8B,#DEB887);

background:-o-linear-gradient(bottom right,#008B8B,#DEB887);

background:-moz-linear-gradient(bottom right,#008B8B,#DEB887);

background:linear-gradient(to bottom right,#008B8B,#DEB887);

}


.grad-FF69B4-2F4F4F{

background:-webkit-linear-gradient(right top,#FF69B4,#2F4F4F);

background:-o-linear-gradient(bottom left ,#FF69B4,#2F4F4F);

background:-moz-linear-gradient(bottom left,#FF69B4,#2F4F4F);

background:linear-gradient(to bottom left,#FF69B4,#2F4F4F);

}


.grad-180-deg{

background:-webkit-linear-gradient(180deg,#0ff,#B8860B);

background:-o-linear-gradient(180deg,#0ff,#B8860B);

background:-moz-linear-gradient(180deg,#0ff,#B8860B);

background:linear-gradient(180deg,#0ff,#B8860B);

}


.grad-90-deg{

background:-webkit-linear-gradient(90deg,#F0F8FF,#B8860B);

background:-o-linear-gradient(90deg,#F0F8FF,#B8860B);

background:-moz-linear-gradient(90deg,#F0F8FF,#B8860B);

background:linear-gradient(90deg,#F0F8FF,#B8860B);

}


.grad-0-deg{

background:-webkit-linear-gradient(0deg,#F0F8FF,#7FFFD4);

background:-o-linear-gradient(0deg,#F0F8FF,#7FFFD4);

background:-moz-linear-gradient(0deg,#F0F8FF,#7FFFD4);

background:linear-gradient(0deg,#F0F8FF,#7FFFD4);

}


.grad-45-deg{

background:-webkit-linear-gradient(30deg,red,blue);

background:-o-linear-gradient(30deg,red,blue);

background:-moz-linear-gradient(30deg,red,blue);

background:linear-gradient(30deg,red,blue);

}


.grad-red-green-blue{

background:-webkit-linear-gradient(red,green,blue);

background:-o-linear-gradient(red,green,blue);

background:-moz-linear-gradient(red,green,blue);

background:linear-gradient(red,green,blue);

}


.grad-r-o-y-g-b-i-v{

background:-webkit-linear-gradient(left,red,orange,yellow,green,blue,indigo,violet);

background:-o-linear-gradient(left,red,orange,yellow,green,blue,indigo,violet);

background:-moz-linear-gradient(left,red,orange,yellow,green,blue,indigo,violet);

background:linear-gradient(to right,red,orange,yellow,green,blue,indigo,violet);

}


.grad-rgba-0-1{

background:-webkit-linear-gradient(left,rgba(255,0,0,0),rgba(255,0,0,1));

background:-o-linear-gradient(left,rgba(255,0,0,0),rgba(255,0,0,1));

background:-moz-linear-gradient(left,rgba(255,0,0,0),rgba(255,0,0,1));

background:linear-gradient(to right,rgba(255,0,0,0),rgba(255,0,0,1));

}


.grad-repeating-lg{

/* Safari 5.1 - 6.0 */

  background: -webkit-repeating-linear-gradient(red, yellow 10%, green 20%);

  /* Opera 11.1 - 12.0 */

  background: -o-repeating-linear-gradient(red, yellow 10%, green 20%);

  /* Firefox 3.6 - 15 */

  background: -moz-repeating-linear-gradient(red, yellow 10%, green 20%);

  /* 标准的语法 */

  background: repeating-linear-gradient(red, yellow 10%, green 20%);

}

</style>


本文转自  素颜猪  51CTO博客,原文链接:http://blog.51cto.com/suyanzhu/1883422
相关文章
|
前端开发 程序员
CSS重复线性渐变之画格子
CSS重复线性渐变之画格子
77 0
CSS 03 线性渐变、径向渐变与重复性渐变
linear-gradient( [ || ,]? , [,]* ) < angle >:用角度指定渐变方向或者角度 to left to right to top to bottom <div class='ceng'> </div> .ceng{ width:260px; height:200px; border:1px solid black; background-image:linear-gradient(orange,green); /*从橘红色向绿色渐变,从上到下*/ background-image:linear-g
|
前端开发 JavaScript 程序员
基于H5+css+JavaScript实现动态线性渐变背景
基于H5+css+JavaScript实现动态线性渐变背景
276 0
基于H5+css+JavaScript实现动态线性渐变背景
|
前端开发
线性渐变背景 CSS linear-gradient() 函数 background-image: linear-gradient()
线性渐变背景 CSS linear-gradient() 函数 background-image: linear-gradient()
126 0
线性渐变背景 CSS linear-gradient() 函数 background-image: linear-gradient()
|
前端开发
CSS:linear-gradient()背景颜色线性渐变
CSS:linear-gradient()背景颜色线性渐变
193 0
CSS3线性渐变
今天来谈谈CSS3中的线性渐变,有了这个,好多以前必须要用图片才能实现的效果如今可能只需简单一行代码就能实现。 首先看看今天的主角: linear-gradient()。
1047 0