我希望文本在中间垂直对齐,如果可能的话,更接近图像。但垂直对齐中间似乎不起作用。此外,当我更改屏幕的宽度时,它不会调整大小,而是从水平行转为垂直,并且无法保留在该部分中。
更改屏幕宽度时:
<section style="background-color:lightblue;">
<div class="container-fluid justify-content-center align-middle text-center pt-2 pb-2" style="max-height:600px">
<div class="row no-gutters align-middle">
<div class="col-lg-5">
<h2>Text</h2>
<p>Et qui deserunt nostrum epellatsitatibus et id veniam eius veniam animi repellat quas.</p>
</div>
<div class="col-lg-2">
<img src='img\img_combined2.png' alt='' style="max-height:600px;"/>
</div>
<div class="col-lg-5 text-center align-middle">
<h2>Text</h2>
<p>Et qui deserunt nostrum voluptates error quod. Quia reiciendis beatae. Hic beatae molestiaeserunt autem. Est necessitatibus et id veniam eius veniam animi repellat quas.</p>
</div>
</div>
</div>
</section>
答案 0 :(得分:1)
max-width:100%;
max-height:100%;
这可能会有所帮助
即使尺寸增加,也可以将它用于适合外部div的图像尺寸
答案 1 :(得分:1)
将align-middle
替换为align-items-center
div
.row
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<section style="background-color:lightblue;">
<div class="container-fluid justify-content-center align-middle text-center pt-2 pb-2" style="max-height:600px">
<div class="row no-gutters align-items-center">
<div class="col-lg-5">
<h2>Text</h2>
<p>Et qui deserunt nostrum epellatsitatibus et id veniam eius veniam animi repellat quas.</p>
</div>
<div class="col-lg-2" style="height:600px">
<img src='img\mywater_img_combine2.png' alt='' style="max-height:600px;"/>
</div>
<div class="col-lg-5 text-center align-middle">
<h2>Text</h2>
<p>Et qui deserunt nostrum voluptates error quod. Quia reiciendis beatae. Hic beatae molestiaeserunt autem. Est necessitatibus et id veniam eius veniam animi repellat quas.</p>
</div>
</div>
</div>
</section>
&#13;
全屏查看