答案:使用CSSposition属性
您可以使用CSS定位方法将DIV的内容与底部对齐。
在下面的示例中,具有.contentclass的DIV元素将放置在.boxDIV元素的底部。让我们尝试一下以了解其实际工作原理:
例试试这个代码»
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CSS Align Content of a Div to the Bottom</title>
<style>
.box{
color: #fff;
background: #000;
position: relative;
min-height: 200px;
padding-bottom: 30px; /* to avoid content overlapping */
}
.box .content{
position: absolute;
bottom: 0;
left: 0;
}
</style>
</head>
<body>
<div class="box">
<h1>Page Title</h1>
<div class="content">This piece of text will remain at the bottom of the parent div all the time.</div>
</div>
</body>
</html>
如需转载,请注明文章出处和来源网址:http://www.divcss5.com/html/h61184.shtml