html - 超大屏幕图像未居中

标签 html css twitter-bootstrap

我有以下标题代码。当我更改为不同尺寸时,图像不居中。如何使所有尺寸 View 的图像居中。

  <div class="jumbotron">
        <img src="images/header.jpg" alt="Banner" class="img-responsive">
   </div>

最佳答案

您可以在您的 css 文件中使用此更改:

// Center all elements in jumbotron, if <img> is not in display block
.jumbotron{
    text-align:center;
}

或者这个,更具体(我更喜欢):

// Set the <img> in display block and use margin auto to center
.jumbotron img{
    display:block;
    margin-left:auto;
    margin-right:auto;
}

关于html - 超大屏幕图像未居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41984596/

相关文章:

javascript - 根据另一个复选框选择显示/隐藏复选框

html - 如何将自定义颜色应用为图像的透明叠加层?

html - 如何在文本区域的右侧启动光标?

twitter-bootstrap - 是否有任何维护良好且及时更新的 compass/sass Bootstrap 项目

html - Bootstrap 4 使网格占据页面其余部分的 100% 高度

html - 为移动端改编一些代码使用 CSS/HTML

css - 如何在 CSS3 和 HTML5 中布局 2 x 3 div(包含图像和文本)的网格

javascript - 字数统计书签

html - 折叠列表溢出

javascript - 使用 Bootstrap 的可折叠菜单