gpt4 book ai didi

html - 屏幕中间的 flexbox 中心图像

转载 作者:太空宇宙 更新时间:2023-11-04 07:51:00 26 4
gpt4 key购买 nike

大家好,有一个简单的问题,在 bootstrap 3 中使用 flexbox,我似乎无法将我的图像居中放置在屏幕中间,我明白了,所以它在中间但现在它在顶部屏幕而不是中心:

HTML:

    <div class="parallaxb">
<div class="homeimgbarber">
<img class="img-responsive" src="img/cuts.png" style="margin: auto;">
</div>
</div>

CSS:

.parallax {
background-image: url("../img/c.png");
min-height: 1000px;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}

.homeimgbarber {
display: flex;
justify-content: center;
align-items: center;
}

最佳答案

这是因为 .homeimgbarber 需要应用高度。

.parallax {
background-image: url("http://via.placeholder.com/350x150");
height: 1000px;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}

.homeimgbarber {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
   <div class="parallaxb">
<div class="homeimgbarber">
<img class="img-responsive" src="http://via.placeholder.com/350x150">
</div>
</div>

关于html - 屏幕中间的 flexbox 中心图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47763942/

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