背景内容图像需要粘在底部

发布于 2024-11-07 23:21:59 字数 569 浏览 4 评论 0原文

我正在尝试推送我的背景内容图像并使其粘在页面底部。该图像不是页脚,因为图像将位于某些内容的后面。但是,当内容很少时,图像不应在顶部被切断,而当内容较多时,图像应粘在底部!

还没有什么工作。有人能给我一些建议吗?

这里有两个例子。一个包含适合窗口的内容,另一个包含更多内容。

这里有两个链接;

http://www.andrewa.org/testing/mosaik-test /content-imagebottom-test.html

http:// /www.andrewa.org/testing/mosaik-test/content-imagebottom-test2.html

提前谢谢你们!

I'm trying to push my background content image and make it stick to bottom of my page. The image is NOT a footer since the image will be behind some of the content. But the image shouldn't get cut off at the top when there is little content and and should stick to the bottom when there is loads of content!

Nothing working quite yet. Anyone got any tips for me?

Here are two examples. One with content fitting the window and the other with a lot more content.

Here are two links;

http://www.andrewa.org/testing/mosaik-test/content-imagebottom-test.html

http://www.andrewa.org/testing/mosaik-test/content-imagebottom-test2.html

Thank you in advance folks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

无声静候 2024-11-14 23:21:59

我将使用 background-attachment:fixed; 将图像作为 body 的背景并添加:

html, body {
  height: 100%;
}

所以总数将是:

html, body {
  height: 100%;
}
body {
  background-image: url("images/bg_content.gif");
  background-position: center bottom;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

I would put the image as a background to the body using background-attachment: fixed; and add:

html, body {
  height: 100%;
}

So the total would be:

html, body {
  height: 100%;
}
body {
  background-image: url("images/bg_content.gif");
  background-position: center bottom;
  background-repeat: no-repeat;
  background-attachment: fixed;
}
别在捏我脸啦 2024-11-14 23:21:59

将背景应用到包装纸上,并将背景位置设置为底部,就像您所做的那样。诀窍是在包装器上设置与背景图像高度相同的最小高度。这将解决内容不足的问题,同时在内容很多时仍然随页面增长。

Apply the background to your wrapper and set the background-position to bottom as you have done. The trick is to set a minimum height on your wrapper that is the same height as your background-image. This will solve the issue of not enough content while still growing with the page when there is lots of content.

江南月 2024-11-14 23:21:59

我相信你的问题有两个方面。首先,您为 #content-image div 设定了高度。去掉那个高度。

其次,因为该 div 中的内容是浮动的,所以您需要清除 #content-image div 上的浮动。类似:“溢出:隐藏;清除:两者”

尝试一下。

I believe your problem is two fold. First, you have a set height for your #content-image div. Remove that height.

Secondly because your content within that div is floated, you need to clear the float on the #content-image div. something like: "overflow:hidden; clear:both"

Try that.

你爱我像她 2024-11-14 23:21:59

粘性页脚和粘性背景合二为一。将背景图像的高度作为页脚高度,并确定内容需要重叠多少图片。要让粘性页脚“消失”,请在主边距底部使用与页脚高度相同的数字。这是来自粘性页脚原始设计的适度设计:http://www. webcreationz.nl/de-ultieme-sticky-footer-code(抱歉,该网站是荷兰语)。

我刚刚想通了这一点。我希望它能帮助某人。

HTML:

<div id="container">

  <div id="main">text of your website</div>

  <div id="spacer"></div>

</div>

<div id="footer"></div>

CSS:

html, body { 
    height: 100%; 
}


#container {
width: auto; /* with number center with margin: 0 auto;*/
    min-height: 100%;
    height: auto !important;
    height: 100%;
    margin-bottom: -175px; /* height footer */
}

#main {
    height: auto;
    width: 618px;
    float: right;
    margin-top: 10px;
    padding: 20px;
    background-color: #FFF;
    border: 1px solid #E1E4EC;
    margin-bottom: -100px; /* overlap of 100 px into footer */

}

#spacer {
    display: block !important;
    height: 175px; /* height footer */
}

#footer {
    clear: both;
    height: 175px; /* height footer */
    width: auto; /* with number center with margin: 0 auto;*/
    background-image: url("images/plaatje jpg"; /* background picture */
    background-repeat: no-repeat;
    background-position: center bottom;
}

A sticky footer and a sticky background in one. Take the height of your background image as your footer height and determine how much of the picture needs to be overlapped by your content. To let the sticky footer "disappear" use the same number in the main margin-bottom as you have for the footer height. This is a moderated design from original design of sticky footer from: http://www.webcreationz.nl/de-ultieme-sticky-footer-code (sorry site is in Dutch).

I just figured this out. I hope it will help someone.

HTML:

<div id="container">

  <div id="main">text of your website</div>

  <div id="spacer"></div>

</div>

<div id="footer"></div>

CSS:

html, body { 
    height: 100%; 
}


#container {
width: auto; /* with number center with margin: 0 auto;*/
    min-height: 100%;
    height: auto !important;
    height: 100%;
    margin-bottom: -175px; /* height footer */
}

#main {
    height: auto;
    width: 618px;
    float: right;
    margin-top: 10px;
    padding: 20px;
    background-color: #FFF;
    border: 1px solid #E1E4EC;
    margin-bottom: -100px; /* overlap of 100 px into footer */

}

#spacer {
    display: block !important;
    height: 175px; /* height footer */
}

#footer {
    clear: both;
    height: 175px; /* height footer */
    width: auto; /* with number center with margin: 0 auto;*/
    background-image: url("images/plaatje jpg"; /* background picture */
    background-repeat: no-repeat;
    background-position: center bottom;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文