兼容IE6,IE7,IE8的元素背景渐变
<!DOCTYPE html><html>
<head>
<meta charset=utf-8 />
<title>CSS 实现元素背景渐变</title>
</head>
<body>
<style type="text/css">
.demo {
width:100%
height:200px
background: -webkit-gradient(linear, 0 0, 0 100%, from(#80c1e7), to(#213c7c))
background: -webkit-linear-gradient(left, #80c1e7, #213c7c)
background: -moz-linear-gradient(left, #80c1e7, #213c7c)
background: -o-linear-gradient(left, #80c1e7, #213c7c)
background: -ms-linear-gradient(left, #80c1e7, #213c7c)
background: linear-gradient(left, #80c1e7, #213c7c)
filter: progid:DXImageTransform.Microsoft.gradient(GradientType = 1, startColorstr = #80c1e7, endColorstr = #213c7c)
}
</style>
<div class="demo"></div>
</body>
</html>
CSS3渐变
渐变.html 文件代码清单如下:
<!doctype html><html lang="zh">
<head>
<meta charset="utf-8">
<title>渐变</title>
<link rel="stylesheet" href="gradient.css">
</head>
<body>
<div id="radial"></div> /* 径向渐变 */
<div id="linear"></div> /* 线型渐变 */
</body>
</html>
gradient.css 文件代码清单如下:
div {width: 500px
height: 300px
}
#radial {
background: -moz-radial-gradient(circle, rgb(255, 0, 0),rgb(0, 0, 255)) /* Firefox */
background: -webkit-radial-gradient(circle, rgb(255, 0, 0),rgb(0, 0, 255)) /* Safari Chrome */
background: -ms-radial-gradient(circle, rgb(255, 0, 0),rgb(0, 0, 255)) /* IE */
background: -o-radial-gradient(circle, rgb(255, 0, 0),rgb(0, 0, 255)) /* Opera*/
}
#linear {
background: -moz-linear-gradient(top, rgb(255, 255, 255), rgb(0, 0, 255)) /* Firefox */
background: -webkit-linear-gradient(top, rgb(255, 255, 255), rgb(0, 0, 255)) /* Safari Chrome */
background: -ms-linear-gradient(top, rgb(255, 255, 255), rgb(0, 0, 255)) /* IE */
background: -o-linear-gradient(top, rgb(255, 255, 255), rgb(0, 0, 255)) /* Opera*/
}