【问题标题】:Background Image Stretch On Homepage主页背景图片拉伸
【发布时间】:2015-12-31 08:49:47
【问题描述】:

我目前正在尝试让我的主页上的背景图片延伸到整个页面,但我很难做到这一点,因为当我尝试重新调整窗口大小时它会变小?

这是我的代码:

<style type="text/css">
            body{
                background: url(img/phantom410.jpg); repeat-y;
                background-size:cover;
                background-color:black;
            }
        </style>

有没有一种方法可以为我的网站主页获取一张图片,并将其拉伸到整个页面,就像 twitter 处理他们的背景图片一样;但是一旦它开始变小就不会收缩吗?谢谢!

【问题讨论】:

    标签: html css twitter


    【解决方案1】:

    body { 
      background: url(https://css-tricks.com/examples/FullPageBackgroundImage/images/bg.jpg) no-repeat center center fixed; 
      -webkit-background-size: cover;
      -moz-background-size: cover;
      -o-background-size: cover;
      background-size: cover;
    }
    h1{
      color:#FFF;
    }
    <html>
      <head>
        <title>Full Background</title>
      </head>
      <body>
        <center><h1>Full Background Image</h1></center>
      </body>
    </html>

    【讨论】:

    • 非常感谢!像魅力一样工作!
    • 欢迎@CaelanGrgurovic!通过接受它作为正确答案来帮助他人。 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-12
    • 2013-12-06
    相关资源
    最近更新 更多