html - 页脚在 body 元素中包含透明背景图像的 div 上方折叠

标签 html css background

我想让背景图片透明,在这里找到了一个很好的答案。但是我的页脚折叠到页眉下方的页面顶部。我可以在正文中看到透明图像,但我的主要文章在应用了 html 背景颜色的页脚下方继续。是什么导致页脚折叠?作为 div 的父容器的部分具有定义的宽度。任何帮助,将不胜感激。

    html {background: #95A3C2;}
body {
    background: white;
    background-image: url(_images/pg_p_lewis_bckgrnd.jpg);
    width: 960px;
    margin: 0 auto 0;
    font-family: "minion-pro";
}
section {
  width: 960px;
  display: block;
  position: relative;
}
#trns {
    height: auto;  
    opacity: 0.2; filter: alpha(opacity=20);
    position: absolute;
    } 
#trnsb {
    height: auto;    
    }
#heading {
    width: 960px;
    }

<body>
<header>
    <div id="colA">
</div>
</header>
<section>
    <div id="trns">
    <div id="trnsb">
    <div id="heading">
    <div id="colD">empty</div>
    </div>
<div id="main">
    <div class="text">
    <p>text</p>
    <p>text</p>
    </div>
<div class="image">
    <p>Image Gallery</p>
    <p><span class="caption">Center image vertically on page and hover to enlarge.</span></p>
    <p><img class="img-zoom" src="_images/RL_LEWIS_Alex_KCC_1197_Sur_1.jpg" class="img-thumbnail" alt="lewis land grant" width="259" height="387"></p>    
    </div>
    </div>
    </div>
    </div>
    </section>
    <footer>
        <div id=copyright>copyright 2016 by Barton Lewis</div>
        <div id=hosting>hosting by simply hosting</div>
    </footer>
</body>
</html>

最佳答案

您已为 #trns 指定了 绝对位置。这样做会从文档的正常流中删除该元素。所以没有什么'推'页脚了。从您的代码中,我看不出给 #trns 绝对位置的理由。您应该能够从您的 css 中删除此声明。

关于html - 页脚在 body 元素中包含透明背景图像的 div 上方折叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40965276/

相关文章:

javascript - 使用 Jquery 动态附加 HTML 返回 [Object object]

html - 如何在 div 中的一行中显示每两个 <p>

javascript - YouTube 嵌入视频播放器的外部播放按钮

html - 包括具有相同样式的文本区域

html - 当我尝试使用 css/html 在我的网站上获取背景时,它不会显示背景

html - Bootstrap : Row margins seen on smaller devices

css - Bootstrap 中有没有办法在小屏幕上将一列设置为 "split"?

html - 并排设置两个div,在其下方设置第三个div

ios - css ipad 2 网站内容在背景上滚动固定

python - PyQt:重置或删除 QTreeWidgetItem 的背景颜色