html - 如何摆脱悬停效果动画显示的这条线?
问题描述
更新:我终于想通了。我不得不在 .services-cell:hover 类中添加溢出:隐藏。
因此,当我将鼠标悬停在图像上时,会出现这种白色条带效果,但是当我将鼠标悬停在图像上时,它会显示一条穿过方形边框的小线,即使形状是多边形。所以基本上想象一个白条从多边形的右上角到左下角。
这是一个代码笔https://codepen.io/designextras/pen/QWybXvR 显示那条小线。即使没有图像显示,当您将鼠标悬停在形状上时它仍然会显示。
我不确定如何摆脱条形图到达图像左下角时显示的那条小线。请注意,当我将鼠标悬停在左上角时,它也会显示线条,所以它看起来有点像边界线效果,但不确定发生了什么。
这是创建效果的 HTML 和 CSS:
html, body {
background: #222;
display: flex;
height: 100%;
overflow: hidden;
align-items: center;
justify-content: center;
}
.services-cell:before {
content: '';
position: absolute;
opacity: 0.4;
width: 350px;
height: 70px;
background: white;
top: 50;
left: 0;
z-index: 1;
transform: rotate(45deg);
transition: transform 0.5s;
}
.services-cell:hover:before {
transform: translate(-100px, 600%) rotate(45deg);
transition: transform 0.5s;
}
.services-cell {
flex: 0 1 250px;
max-width: 250px;
height: 275px;
margin: 2px 2px;
position: relative;
text-align: center;
z-index: 1;
box-shadow: 0px 0px 15px 0 rgba(0, 0, 0, 0.8);
-webkit-clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
cursor: pointer;
}
.services-cell_img {
object-fit: cover;
object-position: center;
}
.services-cell_text {
height: 100%;
width: 60%;
margin: 0 auto;
display: flex;
flex-direction: column;
justify-content: center;
text-transform: uppercase;
color: #fff;
font-weight: 700;
font-size: 1rem;
transition: opacity 350ms;
}
//This is the code that causes the lines
.services-cell:hover {
opacity: 1;
transition: all 0.3s ease-in-out;
transform: scale(1.2);
-webkit-transform: scale(1.2);
z-index: 99;
}
<div class="services-cell">
<img class="services-cell_img" src="https://placehold.it/250x275" alt="">
<div class="services-cell_text">Digital Marketing</div>
</div>
解决方案
在.services-cell:hover, .services-cell_text {
不缩放超过1
,所以改变:
transform: scale(1.2);
to
transform: scale(1);
或者如果您想保持调整大小,请添加:
overflow: hidden;
推荐阅读
- assembly - amd64 MOV 指令未正确复制
- c - 从 netfilter-queued 数据包访问 IP 和 TCP 数据的正确技术是什么?
- css - 如何获得两个 div 标签之间没有空格?
- json - 从API获取数据时如何解决React js中的未定义错误?
- javascript - 如何正确测试作为 Apollo GraphQL 查询的组件?
- java - 在 CompletableFuture.join() 上对方法进行单元测试无限期阻塞
- sql-server - SQL Server 查询中的三个 Shift 明智日期时间检查
- java - 如何从 JWT 令牌身份验证中获取声明值
- powerbuilder - 查询 Powerbuilder 以获取某些复选框并输入 text/singelineedit 以获取 showig 消息框
- c++ - 如何将 crc-32 修改为 crc-32/mpeg-2