css - Bootstrap 4 : Keep a card vertically and horizontally centered but not spill offscreen

标签 css twitter-bootstrap bootstrap-4

我有一个页面,其中只包含一张垂直和水平居中的卡片。该卡片包含一个表格和一些内部文本。用户将提交表单并返回一个列表。有时列表会很长,卡片会在顶部被截断,无法滚动。无论如何让它达到顶峰而不溢出?我试过使用 padding-top,但我不希望宽度影响百分比,而且固定值不适合不同的屏幕尺寸。

CSS

    html,
    body {
        height: 100%;
    }

    .container,
    .row.justify-content-center.align-items-center {
        height: 100%;
        min-height: 100%;
    }

完整示例:http://jsbin.com/madigarixu/edit?html,css,output

最佳答案

你应该试试这个

    html,
    body {
        height: 100%;
    }

    .container,
    .row.justify-content-center.align-items-center {
        height: 100%;
        min-height: 100%;
    }
  .justify-content-center {
    min-height:auto !important;
    height:auto !important;
  }

jsfiddle link update your code

关于css - Bootstrap 4 : Keep a card vertically and horizontally centered but not spill offscreen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43883284/

相关文章:

html - 如何对齐表单元素中心

html - 事件导航栏链接背景颜色保持默认

javascript - 在 Twitter Bootstrap 轮播中显示下一张和上一张图像

css - 如何在 bootstrap/css 中裁剪半张卡片图像?

html - 在 icon-div 中间移动图标

php - 旋转木马显示完美,但不会滑动

css - Django CSS 文件

asp.net-mvc - 如何使用 ASP.NET Razor 语法应用 bootstrap v4 表单输入验证类?

javascript - 是否可以流动子 div 并使用水平溢出使它们填充主 div?

html - 长文本会导致 div 高度出现问题