如何修复剪辑路径切断包裹图像的一小部分?



我正在尝试让剪辑路径容器内的图像正确显示。我也想在悬停时添加轻微的缩放效果。

底部的一小部分在不悬停时被切断。 但是,一旦您将鼠标悬停在图像上并放大,一切看起来都很好。

我无法设置固定高度,这将更容易解决问题,因为我想稍后将图像添加到响应式 flex 容器中。

我在这个jsfiddle中将问题简化为核心:https://jsfiddle.net/pzf459cd/1/

.Image-Wrapper {
width: 50%;
}
.Image-Zoom-Wrapper {
clip-path: polygon(100% 0, 100% 91%, 62% 100%, 0 91%, 0 0, 62% 9%);
object-fit: contain;
}
.Image {
transition: all 0.5s linear;
}
.Image-Wrapper:hover .Image {
transform: scale(1.05, 1.05);
transition: all 0.5s linear;
}
body {
background-color: #000;
}
<div class="Image-Wrapper">
<div class="Image-Zoom-Wrapper">
<img class="Image" src="https://picsum.photos/id/304/500/300">
</div>
</div>

请参阅下面类似任务的解决方案。它有效,但可能有一个更容易/更好的。

JSFIDDLE: https://jsfiddle.net/fj5z7bue/

.wrap{
position: relative;
width: 50%;
filter: drop-shadow(3px 4px 8px rgba(38, 50, 56, 0.4));
}
.clip{
position: relative;
display: block;
overflow: hidden;
clip-path: polygon(60% 5%, 100% 0, 100% 95%, 60% 100%, 0 95%, 0 0);
height: 100%;
width: 100%;
background-color: rgb(240, 240, 240);
}
.pseudoimg{
width: 100%;
opacity: 0;
}
.img{
position: absolute;
top: 0;
left: 0;
z-index: 2;
background-image: url('https://picsum.photos/id/304/500/300');
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
min-height: 100%;
min-width: 100%;
transform: scale(1);
transition: all 0.4s ease-out;
}
.wrap:hover{
cursor: pointer;
}
.wrap:hover .img{
transform: scale(1.4);
transition: all 12s ease-out;
}
.button{
position: absolute;
height: 60px;
width: 60px;
border-radius: 30px;
background-color: rgb(255, 255, 255);
z-index: 3;
right: -15px;
bottom: -5px;
filter: drop-shadow(3px 4px 8px rgba(38, 50, 56, 0.4));
}
<div class="wrap">
	<div class="button"></div>
	<div class="clip">
		<img class="pseudoimg" src="https://picsum.photos/id/304/500/300"/>
		<div class="img"></div>
	</div>
</div>

最新更新