html - 响应式不等尺寸图片库
问题描述
您好一直在研究此https://codepen.io/junedc/pen/yqXVaR以做出响应但无济于事。如果我删除高度或更改为百分比图像丢失。
<div class="gallery-height">
<div class="img" style="height:125px; "></div>
<div class="img" style="height:400px;background-image: url('http://13.210.222.166/wp-content/uploads/2018/07/office1.jpg');"></div>
<div class="img" style="height:130px;"></div>
<div class="img" style="height:300px;background-image: url('http://13.210.222.166/wp-content/uploads/2018/07/office2.jpg');"></div>
<div class="img" style="height:300px;background-image: url('http://13.210.222.166/wp-content/uploads/2018/07/office3.jpg');"></div>
解决方案
如果你真的必须将它用作 css 中的背景图像,这是我喜欢在我的项目中使用的一个技巧:
url('http...') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
推荐阅读
- shell - 检查 ssh 连接是否成功的脚本
- cryptocurrency - 使用php实现bitshares api
- c# - 如何实现字符串相似度算法的数组列表输入?
- java - 模式与文件路径输入不匹配
- android - 从 Google Drive 意图中选择 PDF 或图像文件
- css - HTML/CSS 在第一个 DIV 中指定边框颜色
- html - iText中具有“开始”属性的有序列表
- powershell - 获取 NAS 驱动器信息
- session - Cakephp 3 更新每个请求的会话
- spring-webflux - StepVerifier expectNoEvent for 0ms 不起作用(想检查特殊情况是否有延迟)