2

我前一天问过这个问题。有人也给我一个链接。但是,我无法编写正确的代码。我需要这个背景图片的 CSS:

这个在线生成器中,我已经尝试过了,但我无法生成几乎剩下的纯/纯白色背景色部分:

你能不能,帮帮我。HTML 代码:

<div id="banner" class="outer">
   <div class="inner"></div>
</div>

CSS 代码:

.outer {
    width: 100%;
    float: left;
}
.inner {
    width: 978px;
    margin: 0 auto;
    text-align: left;
    position: relative;
}
#banner {
    display: block;
    float: left;
    margin: 2px 0 0 0;
    padding: 12px 0 0 0;
    height: 290px;
    background: rgb(208,208,208); /* Old browsers */
background: -moz-linear-gradient(left, rgba(208,208,208,1) 0%, rgba(202,202,202,1) 1%, rgba(202,202,202,1) 2%, rgba(223,223,223,1) 9%, rgba(225,225,225,1) 12%, rgba(228,228,228,1) 13%, rgba(228,228,228,1) 53%, rgba(207,207,207,1) 65%, rgba(207,207,207,1) 68%, rgba(198,198,198,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(208,208,208,1)), color-stop(1%,rgba(202,202,202,1)), color-stop(2%,rgba(202,202,202,1)), color-stop(9%,rgba(223,223,223,1)), color-stop(12%,rgba(225,225,225,1)), color-stop(13%,rgba(228,228,228,1)), color-stop(53%,rgba(228,228,228,1)), color-stop(65%,rgba(207,207,207,1)), color-stop(68%,rgba(207,207,207,1)), color-stop(100%,rgba(198,198,198,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, rgba(208,208,208,1) 0%,rgba(202,202,202,1) 1%,rgba(202,202,202,1) 2%,rgba(223,223,223,1) 9%,rgba(225,225,225,1) 12%,rgba(228,228,228,1) 13%,rgba(228,228,228,1) 53%,rgba(207,207,207,1) 65%,rgba(207,207,207,1) 68%,rgba(198,198,198,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, rgba(208,208,208,1) 0%,rgba(202,202,202,1) 1%,rgba(202,202,202,1) 2%,rgba(223,223,223,1) 9%,rgba(225,225,225,1) 12%,rgba(228,228,228,1) 13%,rgba(228,228,228,1) 53%,rgba(207,207,207,1) 65%,rgba(207,207,207,1) 68%,rgba(198,198,198,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, rgba(208,208,208,1) 0%,rgba(202,202,202,1) 1%,rgba(202,202,202,1) 2%,rgba(223,223,223,1) 9%,rgba(225,225,225,1) 12%,rgba(228,228,228,1) 13%,rgba(228,228,228,1) 53%,rgba(207,207,207,1) 65%,rgba(207,207,207,1) 68%,rgba(198,198,198,1) 100%); /* IE10+ */
background: linear-gradient(to right, rgba(208,208,208,1) 0%,rgba(202,202,202,1) 1%,rgba(202,202,202,1) 2%,rgba(223,223,223,1) 9%,rgba(225,225,225,1) 12%,rgba(228,228,228,1) 13%,rgba(228,228,228,1) 53%,rgba(207,207,207,1) 65%,rgba(207,207,207,1) 68%,rgba(198,198,198,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d0d0d0', endColorstr='#c6c6c6',GradientType=1 ); /* IE6-9 */
}
4

2 回答 2

2

该生成器无法正常工作,因为那不是单个渐变;是两个。底部有一个水平渐变,顶部有一个垂直渐变。您可以为此使用多个背景。这就是我想出的:

background: linear-gradient(to bottom, rgba(0, 0, 0, 0.1), transparent 20%, transparent 97%, rgba(0, 0, 0, 0.2)), linear-gradient(to right, #e2e2e2, #fff 40%, #cbcbcb);

如您所见,线性渐变之间有一个逗号,这意味着将第一个渐变合成到第二个渐变之上。您还可以看到我正在使用rgbatransparent在顶部,因此部分显示到底部渐变。

看一看。

于 2013-05-28T00:33:08.363 回答
2

这与您的图像非常接近。它使用径向渐变和嵌入阴影。

http://jsfiddle.net/daCrosby/eZN6Y/

/* Inner Shadow */
-webkit-box-shadow: inset 0px 5px 20px 5px rgba(0, 0, 0, .1);
box-shadow: inset 0px 5px 20px 5px rgba(0, 0, 0, .1);

/* Gradient */
background: #ffffff;
background: -moz-radial-gradient(40% 20%, ellipse cover,  #ffffff 25%, #cccccc 60%);
background: -webkit-gradient(radial, 40% 20%, 0px, 40% 20%, 100%, color-stop(25%,#ffffff), color-stop(600%,#cccccc));
background: -webkit-radial-gradient(40% 20%, ellipse cover,  #ffffff 25%,#cccccc 60%);
background: -o-radial-gradient(40% 20%, ellipse cover,  #ffffff 25%,#cccccc 60%);
background: -ms-radial-gradient(40% 20%, ellipse cover,  #ffffff 25%,#cccccc 60%);
background: radial-gradient(ellipse at 40% 20%,  #ffffff 25%,#cccccc 60%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#cccccc',GradientType=1 );
于 2013-05-28T00:36:30.867 回答