HTML:父块底部内的锚块元素? [英] HTML: Anchor block element inside bottom of parent block?

查看:50
本文介绍了HTML:父块底部内的锚块元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有跨浏览器的方法将< div> 中的某些内容附加到底部?一个难题是÷ div 可能具有任意高度,但是我希望某些内容始终粘贴在其底部.

Is there a cross browser method of attaching some content in a <div> to the bottom? One difficulty is that the <div> may have an arbitrary height applied, but I want certain content to be stuck to the bottom of it at all times.

这可以在像这样的糟糕日子里完成:

This would have been accomplished in the bad old days like this:

<table style="height: foo;">
    <tr><td valign="top">content</td></tr>
    <tr><td valign="bottom">stuck to the bottom</td></tr>
</table>

我可以不借助这种技术来做到这一点吗?

Can I do this without resorting to this technique?

推荐答案

当然,这很容易.只需将父代 div 设置为 position:relative .然后,将要粘贴的内部项目粘贴到底部,只需使用 position:absolute 将其粘贴到项目的底部即可.

Sure, it's pretty easy. Just set the parent div with position:relative. Then, the inner item you want to stick to the bottom, just use position:absolute to stick it to the bottom of the item.

<div id="parent">
    <div id="child">
    </div>
</div>

.

#parent {
  position:relative;
}
#child {
  position:absolute;
  bottom:0;
}

这篇关于HTML:父块底部内的锚块元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆