html - Bootstrap 列以 img 为中心但不以 div 为中心

标签 html css twitter-bootstrap

我在 Bootstrap 列中居中时遇到问题。我有一个使用图像的占位符页面(一个内部有图像和文本的白框),我需要将其更改为方形白色 div,其中添加了图像并手动添加了文本。

当我以第二种方式实现时,我的列突然失去了居中状态。

这是 centered one 的代码笔和 uncentered one .

未居中的相关 HTML:

<div class="col-xs-4 column-centered">
                <a href="../faq/category_3.html">
                    <div class="img-with-text">
                        <img src="img/Blue/VideoCollaboration-Blue.png"></img>
                        <p><b>Video Collaboration</b></p>
                    </div></a>
                </div>

居中相关 HTML:

<div class="col-xs-4 column-centered">
                <div class="img-with-text">
                    <a href="../faq/category_7.html"><img src="img/temp_image.png" alt="VideoCollaboration" /></a>
                </div></div>

我真的很想避免使用偏移量,因为那不是真正居中的..

最佳答案

尝试

.img-with-text{
    display: inline-block;
}

.img-with-text{
    margin: 0 auto;
}

关于html - Bootstrap 列以 img 为中心但不以 div 为中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32850229/

相关文章:

javascript - 如何添加简单的图片上传功能?

javascript - 如果目标元素被删除,带有 "body"容器集的 Bootstrap 弹出窗口不会删除弹出窗口

python - 如何在 PyQt5 中将 HTML 页面保存为 PDF

javascript - 仅使用 javascript 在 div 中加载另一个 html 文件时更改 url

javascript - 制作一个不受 body 类影响的标签

css - 保持 Bootstrap 内联输入元素水平直到 768px?

javascript - AngularJs - 带有ajax加载的模态窗口

html - 我可以在 HTML 元素的名称属性中使用空格吗?

javascript - readFile html参数在 Node 中返回null

javascript - css 删除文本输入样式