简体   繁体   English

具有最小高度的英雄图像:100vh 太大

[英]Hero Image with min-height: 100vh too large

I am using min-height: 100vh on a hero image, but I am noticing on lg-xl screens the image becomes extremely large.我在英雄图像上使用 min-height: 100vh,但我注意到在 lg-xl 屏幕上图像变得非常大。 Is there a way to correct this or cap the height of the hero image without affecting the overlay within the image.有没有办法在不影响图像内的叠加层的情况下纠正此问题或限制英雄图像的高度。 Please note there is an overlay on top of the image so using height 100vh doesn't work My code is as follows:请注意图像顶部有一个叠加层,因此使用高度 100vh 不起作用我的代码如下:

<div className="bg-img"></div>
.bg-img {
min-height: 100vh;
background-image: url('https://storage.googleapis.com/youfit-assets/nologo.png');
background-size: cover;
}

Try doing height: 100vh;尝试做height: 100vh; instead of min-height: 100vh;而不是min-height: 100vh; . . Maybe that is what is bugging you.也许这就是困扰你的原因。

And then I tested it and saw that the attribute className is invalid and should be class .然后我测试了它,发现属性className无效,应该是class

Try this尝试这个

*{
  margin: 0px;
  padding: 0px;
  
 }
 body{
 min-height: 100vh;
 }
.bg-img{
 height: 100vh;
}

This will probably work in your case这可能适用于您的情况

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM