Box-shadow hover transition blinking(盒子阴影悬停过渡闪烁)
问题描述
我正在尝试通过使黑色背景从左到右来使 box-shadow 像 img 上的幻灯片动画一样工作.但是如果没有这个奇怪的闪烁问题,我就无法做到.我已经在 Stack Overflow 上寻找解决方案.
I'm trying to make box-shadow work like a slide animation over an img, by making the black background coming over from left to right. But I can't do it without this weird blinking problem. I've already looked for solutions around Stack Overflow.
我也试过用section代替img,但结果是一样的.
I also tried it with a section instead of an img, but the result was the same.
这里是 JSFiddle 演示
HTML
<section>
</section>
CSS
section {
border:black 1px solid;
width:500px;
height:200px;
transition:1s ease-out
}
section:hover{
box-shadow:inset 500px 0 0 #222;
float:left;
transition:1s ease-out;
}
推荐答案
这似乎是 box-shadow
绘制方式的结果.尝试另一种方法.这是一个无闪烁的解决方案,它可以加厚左边框而不是添加框阴影:
This appears to be a result of the way box-shadow
is painted. Try another approach. Here's a flicker-free solution that thickens the left border instead of adding a box-shadow:
div {
position: relative;
display: inline-block;
}
section {
border: black 1px solid;
width: 500px;
height: 200px;
transition: 1s ease-out;
box-sizing: border-box;
}
div:hover section {
border-left-width: 500px;
float: left;
transition: 1s ease-out;
}
section~* {
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
color: #888;
}
<div class="prog">
<section></section>
<p>Here's some text content.</p>
</div>
https://jsfiddle.net/k5kznmvL/
这篇关于盒子阴影悬停过渡闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:盒子阴影悬停过渡闪烁


基础教程推荐
- 我什么时候应该在导入时使用方括号 2022-01-01
- 当用户滚动离开时如何暂停 youtube 嵌入 2022-01-01
- 角度Apollo设置WatchQuery结果为可用变量 2022-01-01
- 悬停时滑动输入并停留几秒钟 2022-01-01
- Karma-Jasmine:如何正确监视 Modal? 2022-01-01
- 响应更改 div 大小保持纵横比 2022-01-01
- 在for循环中使用setTimeout 2022-01-01
- 有没有办法使用OpenLayers更改OpenStreetMap中某些要素 2022-09-06
- 动态更新多个选择框 2022-01-01
- 在 JS 中获取客户端时区(不是 GMT 偏移量) 2022-01-01