【发布时间】:2021-08-29 03:35:49
【问题描述】:
我遇到了一些问题我试图让两个剪辑路径多边形在鼠标悬停时相互重叠,我正在使用 z-index 并尝试根据覆盖来更改它们,但我似乎无法让它工作。
.banner {
bottom 0;
top: 0;
left:0;
right: 0;
width: 100%;
height: 700px;
position: relative;
}
.overlayleft {
position absolute;
z-index: 1;
bottom 0;
top: 0;
left:0;
right: 0;
width: 50%;
height: 100%;
overflow:hidden;
clip-path: polygon(0 0, 75% 0, 100% 100%, 0% 100%);
background: rgba(0,0,0,1);
transition: .5s ease;
}
.overlayright {
position: absolute;
z-index: 3;
bottom: 0;
top 0;
left: 50%;
right: 0;
width: 50%;
height: 100%;
overflow:hidden;
clip-path: polygon(0 0, 100% 0, 100% 100%, 25% 100%);
background: rgba(0,0,0,0.6);
transition: .5s ease;
}
.overlayright:hover{
width: 100%;
left: 0;
}
.overlayleft:hover{
width: 100%;
}
</style>
</head>
<body>
<div class="banner">
<div class="overlayright"></div>
<div class="overlayleft"></div>
</div>
</body>
【问题讨论】:
标签: html css z-index clip-path