html - 在表格中放置两个div,一个中间和一个底部

标签 html css twitter-bootstrap

我放置了一个响应式的div,一个central和一个bottom;我插入了以下代码:

<link href="../css/bootstrap-theme.min.css" rel="stylesheet" />
<link href="../css/bootstrap.min.css" rel="stylesheet" />
<link href="../css/splashscreen.css" rel="stylesheet" />

<body class="container container-table">
    <div class="text-center col-md-12 col-md-offset-12 vertical-center-row">
        <img class="img-responsive center-block imageCenterContentFirst" src="../images/disegno11.svg" />
    </div>
    <div class="col-md-offset-12 vertical-bottom-row">
        <img class="img-responsive center-block imageCenterContentSecond" src="../images/logo_macnil_zucchetti.svg" />
    </div>
</body>

CSS:

html, body, .container-table {
    height: 100%;
    width: 100% !important;
    padding: 0;
    margin: 0;

}
.container-table {
    display: table;
}
.vertical-center-row {
    display: table-cell;
    vertical-align: middle;
    width: 50%;
}
.vertical-bottom-row {
    display: table-cell;
    vertical-align: bottom;
}

.imageCenterContentFirst {
    width: 100%;
}

这两个 div 没有按照我的意愿对齐,但它们似乎并排出现,如 this image 中所示.其中红色的是第一张图,紫色的是第二张图,而白色和另一部分是两个div,应该是一个在下。

我不明白为什么一个不在另一个下面。

最佳答案

如果您希望两个 div 显示在另一个上方,请尝试使用 display: table-row 而不是 table-cell,作为 display: table; 的直接子级。此外,您已将其中一个 div 设置为 50% 宽度。

.container-table {
    display: table;
}
.vertical-center-row {
    display: table-row;
    vertical-align: middle;
    background:red;
}
.vertical-bottom-row {
    display: table-row;
    vertical-align:bottom;
    background:violet;
}

jsfiddle example

关于html - 在表格中放置两个div,一个中间和一个底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34814407/

相关文章:

javascript - 制作井字游戏,无法制作 'x'

html - TH 在表固定标题中不起作用

html - 如何在不影响标题下方内容的情况下为 header 设置 CSS 样式,使 Logo 位于最左侧,登录名位于最右侧?

javascript - 如何启用和禁用 Twitter Bootstrap 按钮?

jquery - 使粘性侧边栏响应?

javascript - 用/* 开始初始评论的目的!在 javascript 和 css 文件中

html - 2x2 框旁边 1 个大 2x2 大小框使用 css

html - 如何将颜色应用于 SVG 文本元素

ios - 是否可以使flexbox在iphone 4/iOS4上运行或提供后备功能?

css - 我怎样才能解决对 Bootstrap 3 的表单控制类的需求?