html - 图像不能正确缩小
问题描述
所以我有背景图像,当浏览器占据整个屏幕时,它会正确显示。当我缩小浏览器窗口时,图像缩小到一个点,然后突然停止。这就是发生的事情:
我只有一个 .CSS 文件,其中包含:
.fondo {
width: 100%;
height: auto;
position: absolute;
background-repeat: no-repeat;
background-image: url("src/assets/images/fondo.png");
background-size: cover;
background-position: center center;
}
.html 文件有:
<div class="fondo img-fluid"></div>
解决方案
您需要的是高度vh
和宽度vw
:
摆弄玩耍。
.fondo {
height: 100vh;
width: 100vw;
background-repeat: no-repeat;
background-image: url("http://placekitten.com/301/301");
background-size: cover;
background-position: center center;
}
<div class="fondo img-fluid"></div>
推荐阅读
- android - 为什么我会收到此错误“从服务器收到状态代码 401:未经授权”?
- c - C/C++:当服务器重新启动时,客户端永远不会恢复 DTLS 连接
- ios - SwiftUI,如何禁用对列表项的触摸,但对列表项的子视图启用触摸?
- excel - 是否有一个公式可以从一张纸(不包括空白)中捕获所有值并在另一张纸上按顺序显示?
- sql - Postgres alter table 默认为 'NULL::character varying' 而不是 NULL
- c++ - 'binary_semaphore' 尚未在 'std' 中声明
- android - 如何使用 Android Studio 生成 javadoc
- flutter - 横幅广告在列中使用时隐藏 AppBar
- javascript - 如何在页面上打印输入,onClick在文本字段下
- vba - Vba将公式拖放到单独范围的底部