Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/121.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 将具有背景图像的div设置为100%高度_Css - Fatal编程技术网

Css 将具有背景图像的div设置为100%高度

Css 将具有背景图像的div设置为100%高度,css,Css,我想为页面内容设置背景。带有背景图像的div具有class=history。所有高于“历史”和历史本身的div的高度都设置为100%。但是,“历史”div的高度不正确 下面是代码示例。我可能遗漏了一些相关细节,但一旦找到解决方案,我将添加它们。另见 CSS: html, body { height: 100%; background: url(cream_dust.png) repeat 0 0; } HTML: <html> <body class="pag

我想为页面内容设置背景。带有背景图像的div具有
class=history
。所有高于“历史”和历史本身的div的高度都设置为100%。但是,“历史”div的高度不正确

下面是代码示例。我可能遗漏了一些相关细节,但一旦找到解决方案,我将添加它们。另见

CSS:

html, body {
    height: 100%;
    background: url(cream_dust.png) repeat 0 0;
}
HTML:

<html>
<body class="page page-id-41 page-child parent-pageid-8 page-template-default logged-in admin-bar">
<div class="wrapper-for-footer">
<div id="page" class="hfeed site">
<div id="main" class="site-main">
<div id="primary" class="content-


您可能需要添加
位置:绝对
到您尝试为其提供100%高度的
div


编辑:您需要添加
位置:绝对
历史
div
设置为
高度:100%
的元素将只占用其父元素的100%垂直空间。如果在
history
body
之间的某个元素没有高度,那么它就不会像您期望的那样高

大部分
history
元素是浮动内容,因此它已折叠为仅包含非浮动内容

历史记录
元素添加clearfix

溢出:隐藏


你能给问题添加一些html标记吗?这样,即使你已经修复了链接的站点,对未来的访问者来说也是有意义的。这似乎是一个半解决方案。它起作用了,但把其他一切都搞砸了。为什么会这样?这就是
divs
的工作原理。为了获得100%的高度,必须使用绝对定位。你所犯的其他错误来自另一个根源。让我看看有没有发现什么。我给你找到了一个解决办法。。。移除
高度:100%
开始,然后在CSS中设置:
.page-id-41{background:url('http:.your images..png')!重要;}
.history {
    zoom: 1; // fix for IE
}

.history:after {
    content: ' ';
    display: block;
    height: 0;
    clear: both;
    visibility: hidden;
}