当前在线人工客服
天达云-技术
QQ:1324027256
天达云-技术
QQ:1902643386
天达云-售前
QQ:1650874901
天达云-售前
QQ:2207995833
天达云-合作
QQ:1984186903
天达云微信小程序
400-837-6568

怎么用CSS将DIV的内容与底部对齐
更新:HHH   时间:2023-1-7


这篇文章主要介绍了怎么用CSS将DIV的内容与底部对齐,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

答案:使用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">

        <h2>Page Title</h2>

        <div class="content">This piece of text will remain at the bottom of the parent div all the time.</div>

    </div>

</body>

</html>

感谢你能够认真阅读完这篇文章,希望小编分享的“怎么用CSS将DIV的内容与底部对齐”这篇文章对大家有帮助,同时也希望大家多多支持天达云,关注天达云行业资讯频道,更多相关知识等着你来学习!

返回web开发教程...