查看完整版本: [-- DIV+CSS中子div在父div居底 --]

-> 电脑技术 -> DIV+CSS中子div在父div居底 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

网络天下 2012-07-18 11:18

DIV+CSS中子div在父div居底


简单的一个需求, 映射着常常被忽略的知识啊。
上次面试没写出来,得学习。

·思路及要点:

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

· 代码:
  1. <html>
    <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>



查看完整版本: [-- DIV+CSS中子div在父div居底 --] [-- top --]


Powered by phpwind v8.7 Code ©2003-2011 phpwind
Time 0.022748 second(s),query:1 Gzip disabled