我怎样才能给出这个元素的全宽?

时间:2015-02-24 13:32:44

标签: html css

我有这个网站:

http://dl.dg-site.com/functionmentes/

有一个颜色为#D9D9D9

的div

代码CSS:

#full_bar{background:#D9D9D9;width:100%;height:100px;}

我想将我的div作为全宽网站并粘贴到页脚。

我该怎么做?

我在Wordpress中使用主题。

提前致谢!

4 个答案:

答案 0 :(得分:1)

通过固定位置,这将确保在用户向上和向下滚动网站时跟随用户。

#full_bar {
    background: #d9d9d9;
    width: 100%;
    height: 100px;
    position: fixed;
    bottom: 0;
    left: 0;
}

答案 1 :(得分:0)

如果您将position:absolute; left: 0;添加到css中,该栏会或多或少地执行您尝试执行的操作,但这只是一个肮脏的黑客攻击。

真正的问题是,您正在添加&#39; full_bar&#39;在错误的地方(限制宽度的div内)。我个人会选择将全栏放在<footer>标签中。

答案 2 :(得分:0)

您应该将灰色条放在部分之外,部分和页脚之间或页脚之上。

但是如果你想要一个css解决方案,你需要将你的部分父级置于相对位置,并将灰色条设置在绝对底部的全宽:

section {
    position: relative;
    padding-bottom: 100px; // Your bar height
}

#full_bar{
    background:#D9D9D9;
    width:100%;
    height:100px;
    position: absolute;
    bottom: 0;
    left: 0;
}

答案 3 :(得分:0)

您将#full_bar放在class="container"内。 container是div id#full_bar的父级,这就是为什么它不占全宽。 将您的代码放在contaner类之外,您可以看到更改。

查看附件,我认为你想要这个,因为我理解你的问题。

enter image description here

相关问题