css - 在 div 中均匀间隔 href img

标签 css html alignment image

我很难弄清楚如何在 div 容器的两侧均匀地放置 3 个 href img。

视觉示例:[ X X X ]

(X = href img [ ]=容器 div)

<div id="container">
  <a href="#"><img src="image1.jpg"></a>
  <a href="#"><img src="image2.jpg"></a>
  <a href="#"><img src="image3.jpg"></a>
</div>

CSS:

#container {
  clear: both;
  width: 900px;
  height: 150px;
}
#container a img {
  margin: 0 auto;
}

非常感谢任何帮助。谢谢

最佳答案

好的,因为您希望它们均匀分布,我建议使用百分比作为图像的宽度。例如:

#container {
  clear: both;
  width: 900px;
  height: 150px;
}
#container a img {
  float: left;
  width: 33%;
}

这应该使您的 anchor float 在父 div 中,以便它们水平对齐

关于css - 在 div 中均匀间隔 href img,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11859382/

相关文章:

css - 神秘的填充物

css - 在 ember-cli 中安装 Foundation 5

css - 为什么我的链接有无限宽度?

javascript - KineticJS Inside of Shape 和/或 Fill 未在 Windows 8 下的 Chrome 中呈现

php - 检查此邮箱是否已有账户功能不适用于 PHP HTML 和 MySQL

html - 如何垂直对齐单选按钮?

css - html中的垂直表格标题

css - 如何使用 CSS 设置 dijit.Dialog 的样式?

javascript - 我可以将搜索分成不同的 div 吗?

html - 如何水平居中元素?