【发布时间】:2017-11-27 08:04:14
【问题描述】:
我正在开发一个网站,我使用 Bootstrap 行和列分隔一侧的文本和另一侧的图像。
我的 HTML 文件中有以下布局:
<div class="row">
<div class="col-sm">
<h1>This is a very long header with underline</h1>
<h3>This is a subheader</h3>
<p>This is a description</p>
</div>
<div class="col-sm">
<figure class="figure">
<img src="/assets/contentImage4.jpg" alt="Placeholder" class="img-fluid img-thumbnail content-image">
<figcaption class="figure-caption">A caption for the above image.</figcaption>
</figure>
</div>
</div>
这是相关的 CSS:
.figure {
display: block;
margin: auto;
margin-top: 45px;
margin-bottom: 45px;
width: 40%;
text-align: center;
}
h1, h2 {
font-family: 'Work Sans', sans-serif;
border-bottom: 4px solid black;
}
我已将图形的上边距偏移 45 像素,以使图像的顶部与 h1 下方的黑色下划线对齐。然而,在长标题(如本例中)上,h1 换行占据两行,这意味着照片不再排列。有没有办法让它以编程方式适应 h1 的包装方式?
【问题讨论】:
标签: html css twitter-bootstrap bootstrap-4