gpt4 book ai didi

html - 图像未占用父 div 上设置的全宽

转载 作者:行者123 更新时间:2023-11-28 12:25:03 24 4
gpt4 key购买 nike

看到这个 Fiddle

正如您在 fiddle 中看到的,图像左侧有一些空白区域。我已将图像设置为 100% 宽度,但它并没有占用所有空间。您可以通过将鼠标悬停在它上面来检查它。

enter image description here

HTML

<ul class="ulteamlist">
<li class="teamlist">
<img src="http://s21.postimg.org/jpw2o7ofr/image.png">
<div class="overlay"></div>
<p>Vikas Ghodke</p>
<p class="tposition">Lead Developer</p>
</li>
</ul>

CSS

ul.ulteamlist {
margin: 0;
list-style: none;
}
li.teamlist {
background: #fff;
box-shadow: 0px 1px 1px -1px #ccc;
float: left;
padding:0;
display: block;
width:40%;
margin-bottom: 3%;
margin-right: 3%;
transition: all 0.5s;
position: relative;
}
li.teamlist:hover {
background:#0dbca1;
}
li.teamlist:hover p {
color:#fff;
}
.overlay {
width: 100%;
height: 210px;
background: #fff;
position: absolute;
top: 0;
opacity: 0;
transition: all 0.5s;
}
li.teamlist:hover .overlay {
opacity: 0.3;
}
li.teamlist:nth-child(4n+4) {
margin-right: 0;
}
.no-js li.teamlist {
display: block;
}
li.teamlist img {
width: 100%;
height: 210px;
margin:0;
}
.teamlist p {
padding: 10px;
color: #5b5b5b;
font-weight: 400;
font-size: 14px;
padding-left: 15px;
}
p.tposition {
font-weight: 300;
margin-top: -27px;
font-size: 11px;
margin-bottom: 0;
color: #9d9c9c;
text-transform: uppercase;
}

最佳答案

从评论(我的和 OP 的)扩展:

这不是一个“差距”,可以这么说;它是原始图像左侧的一些透明像素:

gap

this fiddle中可以看得很清楚:

<img src="http://s21.postimg.org/jpw2o7ofr/image.png" />
body {
background-color:yellow;
}
img {
outline:1px solid black;
}

使用占位符图片,您的设置看起来不错:

placeholder

http://jsfiddle.net/kDdUC/7/

关于html - 图像未占用父 div 上设置的全宽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18606096/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com