html - 垂直对齐 div 中的内容

标签 html css

<分区>

.info-bg-section {
  background: transparent url(../images/img.jpg) repeat fixed 0 0/cover;
  position: relative;
}

.info-section-colored {
  background-color: #3F3FB5;
  padding: 100px 40px;
}
<div class="info-bg-section dark-bg">
  <div class="container-fluid">
    <div class="row">
      <div class="col-md-4 info-section-colored">
        <p>Content 1</p>
        <p>Content 1</p>
        <p>Content 1</p>
        <p>Content 1</p>
        <p>Content 1</p>
      </div>
      <div class="col-md-8">
        <p>Content 2 </p>
      </div>
    </div>
  </div>
</div>

我想向这个部分(info-bg-section)添加填充。我还想垂直对齐 div 中的内容。

我试着给 div 添加内边距,但看起来这不是个好主意

最佳答案

要垂直对齐内容,您可以使用 vertical-align CSS 属性。可在此处找到更多相关信息:https://www.w3schools.com/cssref/pr_pos_vertical-align.asp .

您可能尝试过或未尝试过的另一个想法是使用百分比进行填充。

关于html - 垂直对齐 div 中的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42483332/

上一篇:html - 大图和小图的 CSS 对齐

下一篇:html - 图像不使用css居中

相关文章:

html - 单独处理按钮 :focus 的按钮行

c# - 如何在 C# 字符串中显示 HTML 内容?

html - Bootbox:消息溢出

javascript - 为什么我的 bootstrap css 类对我的 index.html.erb 没有任何影响?

css - 内容下溢到 CSS 列中的上一列

jquery - 在 jquery 中定位悬停元素

html - 样式 .here 类 - ul div 类

html - Bootstrap 类 ="active"将不起作用

CSS 流式布局,其中页脚 div 跟随页面大小并保持在底部

CSS 固定大小边距仅在元素之间