css - 在一行 HTML 中布局 3 个图像链接

标签 css html

enter image description here

您好,我正在制作一个网站,我需要像上图一样布置一些图片链接。灰色矩形是图像所在位置的占位符,它们的大小相同 (275 x 186),并且它们之间需要一个边距。我还需要能够添加超过 6 张图片。

我似乎无法让它们正确排列。任何帮助将不胜感激。

最佳答案

实现此目的的一种方法是使用 CSS 的“ float ”属性。以下是我将如何解决这个问题。

  1. 创建一个宽度为“275px + border-size”x 3 的 div
  2. 在此 div 中添加所有尺寸为 275 x 186 并带有边框的图片
  3. 为每个图像分配 css 属性“float:left”。

<

style>
    div.wrapper{
    width: ("275 + YOUR border-size" x 3)px;
     }
    div.image{
    background-image: url(..path to your img);
    float: left
    }
</style>

<div class="wrapper">
    <div class="image"></div>
    <div class="image"></div>
    <div class="image"></div>
    <div class="image"></div>
    ... add all your imgs here
    <div style="clear: both"></div> //need this one here to make the wrapper extend 
</div>

关于css - 在一行 HTML 中布局 3 个图像链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18276035/

相关文章:

javascript - jQuery 在两个单独的 div 中按类名选择复选框

css - 在 WebGrid 列中环绕文本

javascript - 将根域重定向到子域的影响

html - html 中的 div 位于同一行

javascript - jQuery 棘手的事情,顶部 slider 更改为从右侧滑动

javascript - 光滑 slider 问题 : Image not showing on initial load

html - PDF报告生成

javascript - 显示随机选择的元素

javascript - 固定面板 extjs 4.2 的大小

html - Bootstrap 封面模板 : where to place image?