html - 将产品图片放在盒子底部

标签 html css image vertical-alignment

CODE

我希望图像在框的底部对齐。会有来自后端的产品图片,并且没有固定尺寸。

HTML

<ul>
  <li><img src="http://img3.wikia.nocookie.net/__cb20120422063108/nickelodeon/images/2/27/Spongebob1.gif" alt="" /></li>
  <li>
    <img src="http://img2.wikia.nocookie.net/__cb20120717231330/hulksmash/images/7/78/Image_placeholder.jpg" alt="" />
  </li>
</ul>

CSS

ul {
  list-style: none;
}
li {
  float: left;
  width: 276px;
  text-align: center;
  border:1px solid #ccc;
  height: 276px;
  margin: 5px
}
img {
  vertical-align: bottom
}

最佳答案

这个 css 成功了

ul {
  list-style: none;
}
li {
  width: 276px;
  text-align: center;
  border:1px solid #ccc;
  height: 276px;
  margin: 5px
  vertical-align: bottom;
  display: table-cell;
  vertical-align: bottom;
}
img {
  vertical-align: bottom
}

关于html - 将产品图片放在盒子底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28836181/

相关文章:

javascript - 在导航栏中居中字形图标

html - '显示 : none' on SVG element with pattern definitions makes patterns invisible

html - Asp.net:不同屏幕分辨率的可变图像源

html - float 元素的奇怪行为似乎具有相对定位

javascript - 带数组的 HTML 5 本地存储

html - 使用 flexbox 将元素包装到新行/行

css - 通过 CSS 仅定位我的图像 Sprite

ios - Firebase 存储图像未在 Tableview 中下载

ruby-on-rails-3 - 处理请求 : invalid byte sequence in UTF-8 时出现意外错误

html - 如何在 CSS 中创建页脚