html - 如何在容器底部设置元素

标签 html css

嗨,我有一个包含许多无序列表的容器。我希望将最后一个无序列表设置为底部的 0 边距。这是我的代码以及我尝试过但不起作用的代码:

<ul id="updates">
              <li>Follow Zack's updates<br/>300 followers. Follows:</li>
              <li><a href="#"><img src="img/zack/update1.png" alt="update"/></a></li>
              <li><a href="#"><img src="img/zack/update2.png" alt="update"/></a></li>
              <li><a href="#"><img src="img/zack/update3.png" alt="update"/></a></li>
              <li><a href="#"><img src="img/zack/update4.png" alt="update"/></a></li>
              <li>+ <br/> 10</li>
          </ul>


<p> Site powered by zi<span>kio<span></p>
div#articles p{
   margin-top: auto;
   margin-bottom: 0
}
ul#updates{
   margin-top: auto;
   margin-bottom: 0;
}

p 和 ul#updates 都需要设置在底部,边距为 0。

*编辑:*父项已设置为position:fixed,因此不能选择相对定位

最佳答案

假设您的列表都是刚刚设置的 div.article 的子级

div.article {
   position: relative; /* after your edit: fixed is fine too */
   padding-bottom : /* enough to make room for last ul */
}

div.article > ul:last-child {
   position : absolute;
   bottom   : 0;
}

关于html - 如何在容器底部设置元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11741376/

相关文章:

html - 如何使用 css 设置 Font Awesome 图标或文本的等量间距

jquery - CSS 动画 : fire css animation on class active

java - 区分具有相同类的两个 html 元素

javascript - 让用户使用 Javascript 在 canvas 中用鼠标绘制矩形

html - 移动 iOS - 固定背景图片解决方案

css - css 正则表达式

html - 谷歌应用引擎 : 405 method not allowed

html - 在部分中更改背景图像不透明度

php - 如何修复不平衡的 thead 和 tbody 的表

html - Web Font Loader 不缓存字体吗?