简体   繁体   English

如何使用css在html中停靠元素

[英]how to dock elements in html using css

i have a main div whose css is : 我有一个主要的div,其css是:

.major
{
width:30%;
height:100%;
position:absolute;
}

now i want to inset an web info at the bottom part which is like 现在我想在底部插入一个Web信息,就像是

about | 关于| terms | 条款| Policies | 政策| Contact us 联系我们

this div is .web_info 这个div是.web_info

so my html is 所以我的HTML是

<div class="major">
<div class="web_info"></div>
</div>

Now i want the web_info div to appear always at the bottom of the parent div ie "major" .. 现在我希望web_info div始终显示在父div的底部,即“major”..

i have treid : 我有畏惧:

.web_info
{
padding-top:90%;
}

But the solution isn't general .. ie compactible for my screen only .. What to do ?? 但解决方案并不通用..即仅适用于我的屏幕..怎么办?

Do you mean something like this one? 你的意思是这样的吗?

.web_info {
    position:absolute;
    bottom:0;
}

So the Div "docks" always at the bottom of the parent div. 所以Div“停靠”始终位于父div的底部。 Important, to get this work the parent div major must have the 重要的是,为了完成这项工作,父div主要必须有

position:relative;

property. 属性。

You'll need another HTML element to set a relative position : 您需要另一个HTML元素来设置相对位置:

<div class="major">
  <div class="innerRelative">
    <div class="web_info"></div>        
  </div>
</div>

See the fiddle working: http://jsfiddle.net/A4GNs/ 看小提琴工作: http//jsfiddle.net/A4GNs/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM