【问题标题】:Size Background Image to fit browser window JavaScript/HTML/CSS/JQuery调整背景图像大小以适合浏览器窗口 JavaScript/HTML/CSS/JQuery
【发布时间】:2012-10-03 14:55:53
【问题描述】:

如何设置背景图像以适合浏览器窗口的确切大小。我熟悉 JavaScript/HTML/CSS/JQuery,所以任何语言都适合我。

【问题讨论】:

标签: javascript jquery html css


【解决方案1】:

HTML 和 CSS:

<html>
<head>
<title>bg</title>
<style>
.bg {
    background: url(yourimage);
    display: block;
    position: absolute;
    width: 100%;
    height: 100%;
}
</style>
</head>

<body>
<div class="bg"></div>
</body>
</html>

【讨论】:

    【解决方案2】:

    我以前为此使用过 Backstretch jQuery 插件。

    http://srobbin.com/jquery-plugins/backstretch/

    【讨论】:

      【解决方案3】:

      感谢@Nelson 的评论,我在这里找到了答案:http://css-tricks.com/perfect-full-page-background-image/

      【讨论】:

        【解决方案4】:

        试试这个:

        <img src="images/BG.jpg" 
        
        style="width:100%;height:100%;position:absolute;top:0;left:0;z-index:-5000;">
        

        http://thewebthought.blogspot.com/2010/10/css-making-background-image-fit-any.html

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2011-09-04
          • 2013-04-19
          • 2021-04-16
          • 1970-01-01
          • 2012-03-23
          • 1970-01-01
          • 2020-08-22
          • 1970-01-01
          相关资源
          最近更新 更多