gpt4 book ai didi

html - 将图像与中间的文本对齐(响应式)

转载 作者:太空宇宙 更新时间:2023-11-04 06:42:10 25 4
gpt4 key购买 nike

美好的一天,我正在尝试将两个 col-md-6 居中,其中带有文本的左侧与图像旁边的中心对齐。这是我的 CSS:

.full_width {
width: 100% !important;
}

.align-row {
display:flex !important;
}

.align-row > *
{
align-self:end !important;
}

我试图将它与 align-row 对齐,但文本位于底部,我们将不胜感激。

issue

<div class="full_width">
<div class="align-row row align-items-center">

<div class="col-md-6 text-align-center">

<span>
<h2 class="color-mwc-blue">SELF-CARE IS SELF-LOVE: 2019 WELLNESS GOALS</h2><br>
<h2 class="color-mwc-orange">REGISTER</h2><br>
<h2 class="color-mwc-blue">TO ENJOY A WELTH OF DEALS FOR WELLNESS</h2>

</span>
</div>

<div class="col-md-6">
<img src="img/_stock_replace_this_1.jpg" class="img-responsive">
</div>

</div>
</div>

PS,我用的是bootstrap 4

最佳答案

使用align-self:center;让元素居中

.align-row > *
{
align-self:center;
}

.full_width {
width: 100%;
}

h2{
font-size:16px;
}

.align-row {
display:flex;
}

.align-row > *
{
align-self:center;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" >

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="full_width">
<div class="align-row row align-items-center">

<div class="col-md-6 text-align-center">

<span>
<h2 class="color-mwc-blue">SELF-CARE IS SELF-LOVE: 2019 WELLNESS GOALS</h2><br>
<h2 class="color-mwc-orange">REGISTER</h2><br>
<h2 class="color-mwc-blue">TO ENJOY A WELTH OF DEALS FOR WELLNESS</h2>

</span>
</div>

<div class="col-md-6">
<img src="https://www.google.co.in/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" class="img-responsive">
</div>

</div>
</div>

关于html - 将图像与中间的文本对齐(响应式),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53645714/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com