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

 Keai丶绿茶_890 发布于 2023-02-10 13:28

当我向我的网页添加背景颜色渐变时,它可以正常工作,直到我的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 个回答
  • 根据您的编辑,问题是背景没有延伸到窗口高度.

    要解决这个问题,只需添加:

    html, body {
        height:100%;
    }
    

    或者,您也可以使用视口百分比单位,如vw:

    body {
        height: 100vh;
    }
    

    你也可以设置一个min-height:

    body {
        min-height: 100vh;
    }
    

    2023-02-10 13:30 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有