html - CSS 图像尺寸不正确
问题描述
我的网站上有这个视差图像(大型自然图像) 这是页面通常的显示方式
但它的大小不合适。当我打开 chrome 开发工具时,它看起来像下面的图像,这就是我想要的样子。 这是应有的形象(自然形象)
所以我想要的是:我希望在上面的图片中看到的自然图像显示为第二张图片(使用 devtools)。我知道图像的尺寸不适合盒子。但我不知道如何修复它,也无法在 Internet 上找到任何东西。
有人能帮我吗?如果我的问题不够清楚,请回复我应该添加的内容!
我的 CSS 代码附加到图像视差:
.header{
background-image: url("nav-bg.png"); //The background image
border-bottom-right-radius: 20px;
border-bottom-left-radius: 20px;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 100% 100%;
}
.parallax-2 {
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
HTML 代码:
<div class="header parallax-2">
<div class="logo fade-in-3"><img src="logo.png" alt="BeldrProductions" width="500"></div>
<!-- The nav-items go here. but i left them out to save space-->
</div>
希望很快能看到你的答案!贝尔德尔
注意:来自以下答案的建议:
- 背景大小:包含不重复;(不工作)
- object-fit:包含和 object-fit:覆盖(不起作用)
- 宽度和高度 100%(不)
我在 JSfiddle 上的代码:https ://jsfiddle.net/BeldrProductions/k5f70dy9/
解决方案
感谢所有帮助过我的人。但我只是在没有图像的情况下使用它
谢谢再见!
如果还有人有解决方案。请把它留在下面。我很乐意看看。
推荐阅读
- reactjs - 调用api时反应webpack代理cors问题
- c - 使用C中的recusion反转数组中的字符
- c# - .ASP NET Core Identity - 无法解析“WebApp.Areas.Identity.Pages.Account.LoginModel”类型的服务
- python - 在 sklearn 或其他聚类库中进行聚类时,有没有办法强制将一组点分配给同一类?
- python - 有没有办法在 Python 中打开 git-bash 并发送命令?
- javascript - 如何将两个数组合并为一个对象?
- r - R-Markdown ggplot网格未正确显示
- python - get_object_or_404 不返回我已验证存在于数据库中的对象
- css - React NextJS CSS - 部分的高度设置为父高度的 100%,但给出页面高度的 100%
- android - 通知通道自定义声音仅在我在模拟器上运行应用程序进程时才有效