gpt4 book ai didi

html - 如何使用 VH 制作响应式英雄背景图片?

转载 作者:行者123 更新时间:2023-11-28 15:18:53 25 4
gpt4 key购买 nike

:)

我有一个响应式标题。

这是英雄部分的代码:

.hero {
background: url(../../img/hero.jpg);
background-size: cover;
background-position: center center;
position: relative;
height: 100vh;
margin: 0;
@include breakpoint($x-large) {
padding-left: 5%;
padding-right: 5%;
}

这一切都很棒而且 react 灵敏;但是,当我在 web 上打开控制台或在 android 上打开键盘时,vh 不会改变,按钮和文本元素保持向下移动。

我试过添加填充和特定媒体查询以及其他解决方案,但我找不到通用有效的解决方案...

为什么会发生这种情况,我该如何解决?

最佳答案

您需要将 .container-hero 附加到 .hero 的底部。

.container-hero {
position: absolute;
bottom: 5%;
}

由于 position: absolute;,您还需要修复布局。

但你明白了:)

关于html - 如何使用 VH 制作响应式英雄背景图片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38626600/

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