如何在没有“窗帘效应”的情况下覆盖整个页面的页面上有渐变背景?

时间:2013-07-15 22:00:52

标签: background gradient background-color css

我希望我的页面有渐变色,从左边的黑暗到中间的明亮,再到右边的黑暗。我已经看到了一些创建渐变的例子,但是我不知道在CSS的哪个位置设置了模式的大小,并且模式重复得太快了。

举个例子,这里有一些CSS:

html {
   background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#2F2727), to(#1a82f7));
   background-image: -webkit-linear-gradient(top, #2F2727, #1a82f7); 
   background-image:    -moz-linear-gradient(top, #2F2727, #1a82f7);
   background-image:     -ms-linear-gradient(top, #2F2727, #1a82f7);
   background-image:      -o-linear-gradient(top, #2F2727, #1a82f7);
}

......我在这里找到了:http://css-tricks.com/css3-gradients/

这是一个可以运行的jsfiddle:

http://jsfiddle.net/clayshannon/VLXbu/

它不能是固定大小,因为手机和台式机之间的差异是屏幕尺寸,特别是。有没有办法用%s的屏幕宽度来实现这个目标?

1 个答案:

答案 0 :(得分:1)

尝试

html {
background: #2f2727; /* Old browsers */
background: -moz-linear-gradient(top, #2f2727 0%, #1a82f7 49%, #1a82f7 49%, #2f2727 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#2f2727), color-stop(49%,#1a82f7), color-stop(49%,#1a82f7), color-stop(100%,#2f2727)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #2f2727 0%,#1a82f7 49%,#1a82f7 49%,#2f2727 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #2f2727 0%,#1a82f7 49%,#1a82f7 49%,#2f2727 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #2f2727 0%,#1a82f7 49%,#1a82f7 49%,#2f2727 100%); /* IE10+ */
background: linear-gradient(to bottom, #2f2727 0%,#1a82f7 49%,#1a82f7 49%,#2f2727 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2f2727', endColorstr='#2f2727',GradientType=0 ); /* IE6-9 */
min-height: 100%; height: auto !important; height: 100%;

}

http://jsfiddle.net/pepean/hSjdg/2/