html - 无法将高分辨率图像放在宽度为 33.3333% 的内联 div 中
问题描述
我创建了 3 个内联 div,占其父宽度的 33.333%,现在我正试图在这些 div 中放置一个图像。可悲的是,如果我放置的图像超过了 div 33.333% 的宽度,图像就会从容器中消失。我正在尝试使图像占据父容器的全宽,但我没有运气。
.wrapper {
width: 70%;
margin: 0 auto;
height: 100%;
}
.gallery-container {
font-size: 0px;
line-height: 0;
margin-bottom: 15px;
}
.gallery-element {
display: inline-block;
width: 33.33333%;
}
.responsive {
width: 100%;
height: auto;
}
<div class="wrapper">
<section>
<div class="gallery-container">
<div class="gallery-element">
<img class='.responsive' src="https://i.imgur.com/wMkl3hm.jpg" alt="">
</div>
<div class="gallery-element">
<img class='.responsive' src="https://i.imgur.com/wMkl3hm.jpg" alt="">
</div>
<div class="gallery-element">
<img class='.responsive' src="https://i.imgur.com/wMkl3hm.jpg" alt="">
</div>
</div>
</section>
</div>
解决方案
删除响应类上的点。
.wrapper {
width: 70%;
margin: 0 auto;
height: 100%;
}
.gallery-container {
font-size: 0px;
line-height: 0;
margin-bottom: 15px;
}
.gallery-element {
display: inline-block;
width: 33.33333%;
}
.responsive {
width: 100%;
height: auto;
}
<div class="wrapper">
<section>
<div class="gallery-container">
<div class="gallery-element">
<img class='responsive' src="https://i.imgur.com/wMkl3hm.jpg" alt="">
</div>
<div class="gallery-element">
<img class='responsive' src="https://i.imgur.com/wMkl3hm.jpg" alt="">
</div>
<div class="gallery-element">
<img class='responsive' src="https://i.imgur.com/wMkl3hm.jpg" alt="">
</div>
</div>
</section>
</div>
推荐阅读
- python - NodeJS中Python进程输出的重复输出问题
- scala - Scalaz 中的类型参数推断
- conda - 默认情况下,在主目录而不是 /opt/miniconda3 中创建 Conda 环境
- c# - 如何将嵌入式图像与后面 C# 代码中的字符串指定的变量 ImageSource 绑定?
- c - 为什么我的转换说明符在 C 中不能正常工作
- vue.js - 每当页面重新加载时,AOS 和 NUXT JS 中的动画块往往会消失
- nginx - Nginx 用作反向代理时删除 ansi 转义码
- javascript - 正则表达式与预期的 \n 字符不匹配
- r - R:使用“doparallel”、“foreach”和“purrr”库重写循环
- ant - 如何使用 Apache Ant 从不同模块收集文件夹(带有文件),避免使用前导文件夹