javascript - 固定/粘性位置对象的颜色变化
问题描述
我看过这个页面(chrome 版本),我想知道那个圆圈会下降并改变颜色。我正在尝试自己做类似的事情,但我陷入了从橙色背景的粉色圆圈到白色背景的绿色圆圈的过渡中。我尝试了两种策略。
a) 使用位置:粘性;+ 将一层隐藏在另一层之下并适当协调,请参见下面的代码。问题是这仅适用于其中一个圆圈(“出现”的那个),但不适用于“隐藏”的那个;所以效果是不一样的。
.yellowbanner {
background-color: yellow;
height: 500px;
width: 500px;
z-index: 2;
position: sticky;
top:50px;
left:0px;
border-radius: 100%;
}
.orangebanner {
background-color: orange;
height: 500px;
width: 500px;
z-index: 21;
position: sticky;
top:50px;
left:0px;
border-radius: 100%;
}
.greenbanner {
background-color: mediumspringgreen;
height: 1000px;
width: 100%;
z-index: 3;
position: relative;
top:500px;
left:0px;
}
.bluebanner {
background-color: blue;
opacity: 1;
height: 1500px;
width: 100%;
z-index: 1;
position: relative;
top:0px;
left:0px;
}
.redbanner {
background-color: white;
height: 3000px;
width: 100%;
z-index: -2;
position: absolute;
top:0;
left:0px;
}
<!DOCTYPE html>
<html>
<head>
<title>DevProject</title>
<link href="./resources/css/index.css" type="text/css" rel="stylesheet">
</head>
<body>
<div class="greenbanner"><div class="yellowbanner"></div></div>
<div class="redbanner"></div>
<div class="bluebanner">
<div class="orangebanner"></div>
</div>
</body>
</html>
B)使用位置:固定;+ 一些 JS。然而,我发现的一切都会改变整个圆圈的颜色(在某个时刻),而不仅仅是它的适当部分。
谢谢
解决方案
推荐阅读
- ruby-on-rails - 如何将两个模型包括数据发送到 ajax 成功调用
- c# - DataTable 列比较差异并将差异写入另一列
- php - 如何计算此表中的平均值
- c# - 如何从 C# 向电报 API 发送发布请求?
- azure-cognitive-search - 如何在 Azure 搜索中处理多词/短语同义词
- react-native - 如何将 TouchableOpacity 与右侧的图标对齐?
- google-cloud-platform - 在谷歌云计算引擎上用 SSD 替换 HDD
- c++ - 我的代码在终端中没有正确执行
- php - 未定义的索引:通过 ajax 调用调用的 php 页面中显示的操作
- sqlite - 当环境变量给出路径时,sqlite3无法打开数据库文件