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>
效果图:
径向渐变:只支持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 display知识详解
推荐阅读
-
css3 线性渐变和径向渐变示例附图
-
利用CSS3的线性渐变linear-gradient制作边框的示例
-
使用canvas来完成线性渐变和径向渐变的功能的方法示例
-
CSS3实现线性渐变用法示例代码详解
-
css背景色渐变之线性渐变和径向渐变的具体用法
-
css3 线性渐变和径向渐变示例附图
-
详解css3径向渐变如何定义中心和大小形状(代码示例)
-
详解css3径向渐变如何定义中心和大小形状(代码示例)
-
css3线性渐变语法的详解(代码示例)
-
【01】CSS3 Gradient 分为 linear-gradient(线性渐变)和 radial-gradient(径 向渐变)_html/css_WEB-ITnose