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>

时间: 2024-10-13 12:07:34

css3 Gradients 线性渐变的相关文章

-webkit-gradient webkit内核浏览器的Linear Gradients (线性渐变) -Css3演示

webkit内核的safari. Chrome的Linear Gradients (线性渐变)的几点说明及演示: webkit内核的safari. Chrome的Linear Gradients (线性渐变) 基本语法:background-image:-webkit-gradient(type,x1 y1, x2 y2, from(开始颜色值),to(结束颜色值), [color-stop(偏移量小数,停靠颜色值),…] ); -webkit-gradient是background的一个属性值

webkit内核浏览器的Linear Gradients (线性渐变)

转自:http://www.css88.com/archives/tag/webkit-gradient webkit内核的safari. Chrome的Linear Gradients (线性渐变)的几点说明及演示: webkit内核的safari. Chrome的Linear Gradients (线性渐变) 基本语法:background-image:-webkit-gradient(type,x1 y1, x2 y2, from(开始颜色值),to(结束颜色值), [color-stop

css3的线性渐变

CSS3 Gradient 分为 linear-gradient(线性渐变)和 radial-gradient(径 向渐变).而我们今天主要是针对线性渐变来剖析其具体的用法.为了更好的应用 CSS3 Gradient,我们需要先了解一下目前的几种现代浏览器的内核,主要有 Mozilla(Firefox,Flock等). WebKit(Safari.Chrome等).Opera(Opera浏览器).Trident(讨厌的IE浏览器). 本文照常忽略IE不管,我们主要看看在 Mozilla.Webk

CSS3 Gradient线性渐变

废话小说,看代码 <!DOCTYPE html > <html > <head> <meta charset="utf-8"> <title>标题</title> <script type="text/javascript" src="../js/jquery-1.4.min.js"></script><style type="text

CSS3的线性渐变(linear-gradient)

以webkit内核浏览器为例, 语法: div{     width:200px;     height:200px;      background:-webkit-linear-gradient(left,#F39,#09C); } 如图: 参数: -webkit-linear-gradient 是 webkit 引擎对渐变的实现参数.第一个参数控制渐变方向,比如 left (由左向右)right(由右向左).第二个和第三个参数,分别是颜色起止颜色. 起止颜色是沿着渐变线,将会在指定位置(以

CSS3背景线性渐变

5.背景线性渐变:background-gradient (1)linear:线性渐变, 谷歌浏览器:(webkit) background:-webkit-gradient(linear ,0 0,0 80% , from(#fff),  to(#000));(水平渐变) background:-webkit-gradient(linear ,0 0, 80% 0 , from(#fff),  to(#000));(垂直渐变) background:-webkit-gradient(linea

【CSS3】 线性渐变

参考地址:http://www.w3cplus.com/css3/new-css3-linear-gradient.html background-image: linear-gradient(to bottom, //渐变方向#d9edf7 //开始颜色0px, //?????#b9def0 //结束颜色100%); //透明 百分比 background-image: -webkit-linear-gradien(to bottom, #d9edf7 0px, #b9def0 100%);

Css3渐变(Gradients)-径向渐变

CSS3径向渐变-radial-gradient()/repeating-radial-gradient() 径向渐变由它的中心定义. 创建径向渐变,至少定义两种颜色节点,呈现平稳过度的颜色.同时,你也可以指定渐变中心.形状(圆形或椭圆形).大小. 默认情况下,渐变的中心是center(表示在中心),渐变的形状是ellipse(表示椭圆形),变天的大小是farthest-corner(表示到最远的角落) 语法: background: radial-gradient(center, shape

深入理解CSS3 gradient斜向线性渐变——张鑫旭

by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=3639 一.问题没有想得那么简单 提问,使用CSS3 gradient渐变,在一个400*300的div层上实现一个(100px, 100px)到(200px, 200px)由红到黄的斜向线性渐变,该如何实现? //zxx: 这里的讨论CSS3渐变都是基于新式规范写法,且忽略私有前缀 我们可能知道水平渐变的实现,类似这样