【发布时间】:2019-06-30 11:20:57
【问题描述】:
我有一个元素想要“扩展”并更改页面背景的背景颜色。当用户滚动时,中心的一个点将扩展以用新的背景颜色填充页面。我看到了如何更改背景的示例,但没有看到如何“扩展”它。 I have attached a jsfiddle of the CSS animation effect I'm looking for. 这个例子展示了它的外观,但只适用于悬停。如果您滚动示例并将鼠标悬停在白点上,您可以看到它应该是什么样子。1
最好我想用 css 动画来完成这个,但我不反对用 javascript 来尝试。 I've been fiddling around with that here.
其次,我一直在使用假元素来获取示例,但是有没有一种方法可以在不需要元素并且只使用容器的背景颜色的情况下实现这种效果?
这是我想要实现的效果示例的 HTML。
<div class="container">
<span class="white"></span>
</div>
这是 CSS:
.container {height:500px;width:100%;background:#ed565d;position:relative;}
.container span {display:block;}
.white {background:#ffffff;height:10px;width:10px;margin:auto;border-radius:100%;position:absolute;top:50%;left:50%;}
.container:hover .white {
width:300%;
height:300%;
-moz-transition: all 0.5s ease-out;
-o-transition: all 0.5s ease-out;
-webkit-transition: all 0.5s ease-out;
transition:all 0.5s ease-out;
top:-100%;
left:-100%;
}
【问题讨论】:
标签: javascript css animation css-animations