背景渐变无法正确显示bootstrap 3

时间:2013-12-15 01:54:44

标签: html css3 twitter-bootstrap-3 css

当我向我的网页添加背景颜色渐变时,它可以正常工作,直到我的body元素中最后一个容器的结尾。之后,渐变停止工作,您会在容器的末尾和空白页的其余部分之间看到明显的对比。

亲眼看看:

从layoutit.com下载默认网页,然后使用以下命令编辑css / style.css

body {
  background: #1e5799; /* Old browsers */
  background: -moz-linear-gradient(top,  #1e5799 0%, #207cca 30%, #2989d8 50%, #7db9e8 100%); /* FF3.6+ */
  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(30%,#207cca), color-stop(50%,#2989d8), color-stop(100%,#7db9e8)); /* Chrome,Safari4+ */
  background: -webkit-linear-gradient(top,  #1e5799 0%,#207cca 30%,#2989d8 50%,#7db9e8 100%); /* Chrome10+,Safari5.1+ */
  background: -o-linear-gradient(top,  #1e5799 0%,#207cca 30%,#2989d8 50%,#7db9e8 100%); /* Opera 11.10+ */
  background: -ms-linear-gradient(top,  #1e5799 0%,#207cca 30%,#2989d8 50%,#7db9e8 100%); /* IE10+ */
  background: linear-gradient(to bottom,  #1e5799 0%,#207cca 30%,#2989d8 50%,#7db9e8 100%); /* W3C */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#7db9e8',GradientType=0 ); /* IE6-9 */
}

css是由http://www.colorzilla.com/gradient-editor/生成的,所以我相当肯定它是有效的,因为它似乎是制作渐变的流行选择,它可以在非引导页面上运行。

关于如何在整个页面中渲染渐变的任何想法?

修改 查看http://theshachar.com/so/

上的示例

谢谢!

1 个答案:

答案 0 :(得分:5)

根据您的编辑,问题是背景没有延伸到窗口高度。

要解决此问题,只需添加:

html, body {
    height:100%;
}

或者,您也可以使用vw之类的viewport-percentage units

body {
    height: 100vh;
}

您还可以设置min-height

body {
    min-height: 100vh;
}
相关问题