html - 背景图像太放大
问题描述
我在 div 上的背景图像看起来过于放大并且不清楚它失去了清晰度这是我尝试过的 html 和样式
<div class="grid-x intro">
<div class="cell large-12 medium-12 small-12 one">
</div>
</div>
<!-- end of intro -->
styling
.intro{
background-image: url("../images/house4.jpg");
background-size: cover;
background-repeat: no-repeat;
width: 100%;
/* height: auto; */
padding-top: 66.64%;
}
解决方案
在这里没关系...使用
"background-size: 100% auto;"
这是因为您的图像比您使用的高度更宽background-size: cover;
。为了覆盖所有背景,这就是为什么它被缩放和裁剪的剩余宽度 你的代码是好的,只需使用调整大小的图像,如 500px*333.2px(或大约这个比例)来显示 66.64% 填充内的所有图像.intro{ background-image: url("https://image.freepik.com/free-vector/geometric-models-gradient-background_23-2148326516.jpg"); background-size: 100% auto; background-repeat: no-repeat; width: 100%; /* height: auto; */ padding-top: 66.64%; }
<div class="grid-x intro"> <div class="cell large-12 medium-12 small-12 one"> </div> </div> <!-- end of intro -->
推荐阅读
- c# - FFMPEGAutogen 示例中可能存在内存泄漏
- leaflet - 传单:使用 geoJson 图层时如何为标记添加颜色?
- sql - 创建一个 sql server 作业以从其他表中填充一个表
- azure - 在 SQL Server 部署任务中设置 Azure Pipeline 变量值以进行备份
- jquery - 如何制作两个元素的动画。一个元素慢慢地休息,把他藏起来
- javascript - Google AdminDirectory API - 访问许可证信息和自定义架构
- excel - 自动化我的银行对账单 - 使其动态化
- javascript - Rxjs ReplaySubject & 成对
- javascript - 电子图像的异步缩放
- php - 带有 API 平台的 Doctrine 查询结果缓存