欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

css3 线性渐变和径向渐变示例附图

程序员文章站 2022-05-30 22:58:06
本文为大家介绍下css3 线性渐变和径向渐变的应用示例,线性渐变:ie6以下不兼容;径向渐变:只支持firefox、Chrome和Safari,需要的朋友可以参考下... 14-04-08...
线性渐变:ie6以下不兼容

径向渐变:只支持firefox、chrome和safari

复制代码
代码如下:

<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html" charset="utf-8" />
<title>background color</title>
<style type="text/css">
* {
marigin:0;
padding:0;
}
div{
margin-bottom:20px;
width:300px;
height:100px;
}
.linear{/*线性渐变样式*/
background-color: #1fa9f4; /* old browsers */
background-image: -moz-linear-gradient(top,#1fa9f4 0%, #001c4e 100%); /* ff3.6+ */
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1fa9f4), color-stop(100%,#001c4e)); /* chrome,safari4+ */
background-image: -o-linear-gradient(top,#1fa9f4 0%, #001c4e 100%); /* opera 11.10+ */
background-image: -ms-linear-gradient(top,#1fa9f4 0%, #001c4e 100%); /* ie10+ */
background-image: linear-gradient(to bottom,#1fa9f4 0%, #001c4e 100%); /* w3c */
filter: progid:dximagetransform.microsoft.gradient( startcolorstr='#1fa9f4', endcolorstr='#001c4e',gradienttype=0 ); /* ie6-8 */
}
.circle{/*径向渐变样式*/
background-color: #1fa9f4; /* other browsers*/
background-image:-moz-radial-gradient(center 80px 45deg, circle farthest-corner, #1fa9f4 0%, #001c4e 100%); /* ff3.6+ */
background-image: -webkit-gradient(radial,50% 100%,10,50% 50%,90,from(rgba(31,169,244,1)),to(rgba(0,28,78,1))); /* chrome,safari4+ */
}
</style>
</head>
<body>
<div class="linear">
</div>
<div class="circle">
</div>
</body>
</html>

效果图:
css3 线性渐变和径向渐变示例附图