html - 显示 : inline-block wont center in bootstrap

标签 html css twitter-bootstrap

我试图使内容框适合文本的长度,同时将它们置于我的图像下方。我正在使用 Bootstrap 网格系统。

HTML

<div class="row textbackground">
    <div class="col-md-4">
        <img class="imgsize img-fluid" src="math.jpg" alt="student">
        <p class="subtext text-center" >Student by Day</p>
    </div>
    <div class="col-md-4">
        <img class="imgsize img-fluid" src="coder.jpeg" alt="web design">
        <p class="subtext text-center" >Evening Web Developer</p>
    </div>
    <div class="col-md-4">
        <img class="imgsize img-fluid" src="rockstar.jpg" alt="rockstar">
        <p class="subtext">Rockstar by Night</p>
    </div>
</div>

CSS

.imgsize{
    height: 250px;
    width: auto;
    border-style: solid;
    border-width: 10px;
    border-radius: 50%;
    border-color: #111111;
    display: block;
    margin:0 auto;
}

.subtext{
    padding-top: 20px;
    background-color: #6c757d;
    display: inline-block;
    text-align: center;
}

结果

This is what I end up with

最佳答案

在您的案例中将文本中心类添加到父元素 col-md-4

您尝试在本身不居中也不是全宽的元素内文本中心。

关于html - 显示 : inline-block wont center in bootstrap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45786632/

相关文章:

javascript - 下拉子菜单不会保持打开状态

twitter-bootstrap - laravel 链接确实有效,但按钮无效

jquery - 是否有可能让具有 html 标记的变量在 jquery 中具有 appendTo 函数?

javascript - 是否可以使这个脚本更加高效?

html - 在悬停模式下动画填充 SVG

php - Bootstrap 导航、旋转木马和页脚中出现的垂直滚动条

JavaScript - 平滑移动/调整大小

html - 在 CSS 中如何编辑 HTML 表单元素?我要分配一个ID吗?

html - 添加新过渡后导航栏显示异常

css - IE 9圆 Angular 带背景图片