Css 如何将div浮动到内容的最底部
如何将div浮动到内容的最底部? 因此,在我的页面结束时,无论内容生成多长时间,我都希望有某种页脚,但我不想使用页脚标记,我也需要在其他页面中实现它 在本例中,它是关于division class=bottom的 我的代码在下面Css 如何将div浮动到内容的最底部,css,position,footer,Css,Position,Footer,如何将div浮动到内容的最底部? 因此,在我的页面结束时,无论内容生成多长时间,我都希望有某种页脚,但我不想使用页脚标记,我也需要在其他页面中实现它 在本例中,它是关于division class=bottom的 我的代码在下面 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=devi
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=yes">
<title>Moworkflow app</title>
<link rel="stylesheet" type="text/css" href="advertentie.css" />
<head>
<body>
<!-- wrapper -->
<div id="wrapper">
<!-- header -->
<div id="header" align="center">
<ul>
<li><a href="#">img logo</a></li>
<li><a href="#">Aanbod</a></li>
<li><a href="#">Vraag</a></li>
</ul>
</div>
<!-- filter -->
<div id="filter">
</div>
<!-- content -->
<div id="content" align="center">
<table cellspacing="10" class="tablestyle">
<tr>
<td><h3>Advertentiegegevens</h3></td>
</tr>
<tr>
<td>Soortnaam</td>
</tr>
<tr>
<td><input type="text" class="invoerveld"></td>
</tr>
<tr>
<td>Kleur</td>
</tr>
<tr>
<td><input type="text" class="invoerveld"></td>
</tr>
<tr>
<td>Aantal</td>
</tr>
<tr>
<td><input type="text" class="invoerveld"></td>
</tr>
<tr>
<td>Prijs</td>
</tr>
<tr>
<td><input type="text" class="invoerveld"></td>
</tr>
</table>
</div>
<!-- bottom -->
<div id="bottom" align="center">
</div>
</body>
</html>
body {
margin:0;
width:100vw;
background:#fff;
font-family: arial;
}
#wrapper {
position: absolute;
height: 100%;
min-height: 456px;
width: 100%;
}
#header {
position: fixed;
width: 100%;
height: 60px;
background: #0d82d7;
z-index: 4;
opacity: 0.96;
}
ul {
display: table;
width: 100%;
height: 60px;
list-style: none;
padding-left:0;
margin:0;
}
li {
display: table-cell;
text-align: center;
line-height: 60px;
text-decoration: none;
border-right: 1px solid #0d82d7;
}
li a {
text-decoration: none;
color: white;
}
#filter {
background: #0873c0;
position: fixed;
top: 60px;
width: 100%;
height: 30px;
z-index: 3;
opacity: 0.96;
}
#content {
position: absolute;
background-color: white;
width: 100%;
top: 70px;
margin-top: 20px;
bottom: 30px;
display: table;
z-index: 0;
}
.tablestyle {
width: 100%;
padding: 5px;
padding-left: 50px;
padding-right: 50px;
}
.invoerveld {
width: 100%;
height: 30px;
border-radius: 5px;
border-color: #0d82d7;
border-style: solid;
border-width: 1px;
margin-bottom: 10px;
}
#bottom {
position: relative;
width: 100%;
background-color: #0d82d7;
height: 30px;
bottom: 0px;
margin-bottom: 0px;
opacity: 0.9;
}
使用以下命令更改底部ID css:
#bottom {
position: fixed;
width: 100%;
background-color: #0d82d7;
height: 30px;
margin-bottom: 0px;
opacity: 0.9;
bottom:0;
}
还要检查JSFIDLE,您是否希望它是这样
如果希望页脚跟随内容,应删除以下内容:
#content {position:absolute;}
原因是,绝对定位元素从页面正常流中取出,因此以下同级元素不会像通常那样定位在它们下面
更新:
为了避免页脚+内容短于浏览器高度,您可以将内容的100%高度减去页眉高度。。大概是这样的:
#content {min-height:calc(100% - 50px);}
浏览器支持:
这会将一个元素与某个元素的底部对齐,如果希望包含该元素,请给出父位置:相对 这只是固定的,我不希望它一直都是可视的,它需要在内容下方浮动。OP要求页脚在内容下方浮动,无论多长时间,在您的解决方案中,无论内容高度如何,页脚都会固定在页面底部。。。如果长一点>看起来不错,谢谢。它在内容下面浮动得很好,但是现在如果内容比浏览器大小小,页脚就会在屏幕中间结束。有没有办法解决这个问题?是的,你可以用calc给出最小高度。。我会更新答案。是的,这太棒了,但我现在看到我的内容升级了。内容的状态与以前不同。这和你的改变有关吗?它移到了我的导航/标题栏下方,现在发生的是你的标题+填充元素是固定的,所以你需要给你的内容添加匹配的填充,这样它就可以在它们之后开始。。因此收割台+填料高度=90px。。将内容填充设置为90像素。。此外,我还更改了最小高度以减少页脚高度。。检查代码>
.bottom {
position:absolute;
bottom:0;
left:0;right:0;
margin:auto auto;
}