css - Twitter Bootstrap - 宝丽来效果 (CSS) 移动网格

标签 css twitter-bootstrap

<分区>

我正在使用 Twitter Bootstrap 构建一个页面。要显示图片库,我使用如下设置:

<div class="container">
    <div class="row">
        <div class="span1">
            <a href="#">
                <img src="http://www.placehold.it/50x50" />
            </a>
        </div><!-- /.span -->
        <div class="span1">
            <a href="#">
                <img src="http://www.placehold.it/50x50" />
            </a>
        </div><!-- /.span -->
        <div class="span1">
            <a href="#">
                <img src="http://www.placehold.it/50x50" />
            </a>
        </div><!-- /.span -->
    </div><!-- /.row -->
</div><!-- /.container -->

Fiddle

现在我想要对这些图像产生某种宝丽来效果。为此,我添加了一个包含 aimg 的类 photo。像这样:

<div class="span1">
    <div class="photo">
        <a href="#">
            <img src="http://www.placehold.it/50x50" />
        </a>
    </div>
</div><!-- /.span -->

Fiddle

如您所见,添加此类会以某种方式移动网格。这就是网格不再居中的原因。我能做些什么来解决这个问题吗?

如果 span 有一个 background-color 并且图像位于 span 的中心,那将是最好的。我相信使用填充我可以控制边框的宽度 - 这是最初的想法,但它不起作用。你会如何创造这样的效果。使用 border-iage 也会移动网格。

我添加了一些截图:

这是第一个例子——视觉居中 Example 1

第二个例子 - 明显转移 Example 2

最佳答案

问题解决了。忘记了我已将 widthheight 添加到 .photo。删除这些值后,它会正常工作。

关于css - Twitter Bootstrap - 宝丽来效果 (CSS) 移动网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11622251/

上一篇:CSS:position:absolute div inside position:relative div——我做错了什么?

下一篇:css - @font-face 不适用于任何浏览器

相关文章:

html - 如何在 Bootstrap 中将列包装在较短的列下

html - 具有不同高度列的 Bootstrap 行

html - 对齐自举网格

html - 中心表格显示 :table-cell

html - 如何在将鼠标悬停在元素上时阻止其他表格元素向右移动

css - Nivo 背景位置被忽略

javascript - 当您访问其中包含特定 ID 的 URL 时添加 CSS

javascript - 使用 holder.js 显示图片缩略图

javascript - 如何让预加载器在加载图像后等待?

html - 输入和按钮在同一行,右浮动