首页 > 开发 > CSS > 正文

如何让子DIV在父DIV的低端

2023-04-12 19:32:26
字体:
来源:转载
供稿:网友

本文通过使用CSS控制子DIV显示在父DIV的低端,具体思路:

父div的位置设置成相对的,即“position: relative;”。而子div的位置设置成绝对的,并且下边缘设为0,即“position: absolute; bottom: 0;”。

代码:

<head>    <title>子div在父div中置底</title>    <style type="text/css">        .father { width: 500px; height: 600px; position: relative; background-color: AliceBlue; }        .child { width: 400px; height: 100px; position: absolute; bottom: 0; background-color: AntiqueWhite; }    </style></head><body>    <div class="father">        <div class="child">        </div>    </div></body></html>
 
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表