【问题标题】:How do I align a picture and its caption horizontally within 3 columns如何在 3 列内水平对齐图片及其标题
【发布时间】:2016-12-18 20:53:22
【问题描述】:

使用引导程序,我创建了三列,每列包含一个图像和一个标题。像这样:

但是,我希望它实际输出这样的内容:

这是我当前的代码:

<!-- Section 6 -->
<div class="cssSection cssCenter">
    <div class="container">
        <h2>The Order</h2>
        <br>
        <p class="cssInformation">Labelled as a religious order, the Knights Templars established a set of rules by which their members would follow.</p>
        <br>
        <div class="row">
            <div class="col-sm-4">
                <img class="img-center img-responsive" src="http://placehold.it/400x275">
                <br>
                    <p>The Templars swore to an oath of poverty, chastity, obedience and renounced the world.</p>
            </div>
            <div class="col-sm-4">
                <img class="img-center img-responsive" src="http://placehold.it/400x275">
                <br>
                    <p>The Templars lived within their own community, which meant sleeping in a common dorm, while also eating their meals in union. Lorem ipsum sont dolor sit amet. Lorem ipsum sont dolor sit amet.Lorem ipsum sont dolor sit amet.</p>
            </div>
            <div class="col-sm-4">
                <img class="img-center img-responsive" src="http://placehold.it/400x275">
                <br>
                    <p>The Templars refrained from becoming drunk, gambling and swearing</p>
            </div>
        </div>
    </div>
</div>

这里是相关的 CSS 代码:

.cssSection {
    padding: 45px 0 30px;
}

.cssCenter {
    text-align: center;
}

.cssInformation {
    font-size: 18px;
}

我可以在 HTML 和/或 CSS 中进行哪些调整以使 p 标签水平对齐而不影响图像?

【问题讨论】:

标签: html css twitter-bootstrap alignment


【解决方案1】:

您的代码在 bootstrap3.3.4 中运行良好。 检查您的引导程序版本。

【讨论】:

    【解决方案2】:

    在 plunker 中一切都很好。请提供您的整个 html 文件以帮助我们检查您的问题。

    【讨论】:

      【解决方案3】:

      您确定没有添加其他 CSS 吗?我在 jsfiddle 上尝试了你的代码(添加引导程序),它对我来说很好。

      【讨论】:

        猜你喜欢
        • 2017-09-29
        • 1970-01-01
        • 1970-01-01
        • 2016-03-25
        • 1970-01-01
        • 2017-10-08
        • 1970-01-01
        • 2011-01-26
        • 1970-01-01
        相关资源
        最近更新 更多