答案 0 :(得分:5)
我真的看不到那个小图片,但我建议你尝试一下在线CSS3生成器,就像这样:
答案 1 :(得分:1)
以下是您正在寻找CSS的代码。
~~ HTML ~~
<DIV class="mygradient"></DIV>
~~ CSS ~~
.mygradient{
height:300px;
width:100px;
background: #7a0000; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzdhMDAwMCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjYzJSIgc3RvcC1jb2xvcj0iIzkwMDAwMCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9Ijk2JSIgc3RvcC1jb2xvcj0iIzk0MDAwMCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM2NTAwMDAiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, #7a0000 0%, #900000 63%, #940000 96%, #650000 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#7a0000), color-stop(63%,#900000), color-stop(96%,#940000), color-stop(100%,#650000)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #7a0000 0%,#900000 63%,#940000 96%,#650000 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #7a0000 0%,#900000 63%,#940000 96%,#650000 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #7a0000 0%,#900000 63%,#940000 96%,#650000 100%); /* IE10+ */
background: linear-gradient(to bottom, #7a0000 0%,#900000 63%,#940000 96%,#650000 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7a0000', endColorstr='#650000',GradientType=0 ); /* IE6-8 */
}
为所有具有IE9支持渐变的元素添加“渐变”类。
~~ HTML ~~
<DIV class="mygradient gradient"></DIV>
并在HTML中添加以下覆盖以完成IE9支持:
~~ HTML ~~ for IE9 FULL SUPPORT
<!--[if gte IE 9]>
<style type="text/css">
.gradient {
filter: none;
}
</style>
<![endif]-->
答案 2 :(得分:0)
CSS3提供了一种更加跨浏览的方式。
示例
.box_gradient {
background-color: #fff;
/* Chrome 10+, Saf5.1+ */
background-image: -webkit-linear-gradient(top, #fff, #ddd);
/* FF3.6 */
background-image: -moz-linear-gradient(top, #fff, #ddd);
/* Opera 11.10+ */
background-image: -o-linear-gradient(top, #fff, #ddd);
background-image: linear-gradient(top, #fff, #ddd);
/* IE6–IE9 */
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffffff', EndColorStr='#dddddd');
}
您的html和body标签需要100%高度。