html - 部分不从页面底部移动到顶部
问题描述
我正在尝试为从底部页面到顶部的部分内的段落设置动画,但它不起作用。
我该如何解决这个问题?
body {
background: rgb(196, 56, 56);
height: 100%;
width: 100%;
}
section {
position: relative;
}
section p {
color: rgb(235, 197, 31);
animation: 1s slid;
}
@keyframes slid {
0% {
bottom: -100;
opacity: 0;
}
100% {
bottom: 0;
opacity: 1;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="test.css" />
<title>Document</title>
</head>
<body>
<section>
<p>I'm YASER</p>
</section>
</body>
</html>
解决方案
尝试transform
:
body {
background: rgb(196, 56, 56);
height: 100%;
width: 100%;
}
section {
position: relative;
}
section p {
color: rgb(235, 197, 31);
animation: 1s slid;
}
@keyframes slid {
0% {
transform: translateY(-100px);
opacity: 0;
}
100% {
transform: translateY(0px);
opacity: 1;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="test.css" />
<title>Document</title>
</head>
<body>
<section>
<p>I'm YASER</p>
</section>
</body>
</html>
推荐阅读
- python-3.x - Python中的多线程问题 - 我怎样才能使它正常工作?
- c++ - 以垂直列表/或 C++ 中的文本的形式对齐文本
- typescript - 使用模块 xlsx-style 和 xlsx 将图像添加到 xlsx 文档
- reactjs - 我无法将变量传递给函数 ReactJS 之外的函数
- java - 合并多个 LiveData 源?
- pandas - Pandas:按整数选择数据框中的多列
- c# - 当方法被另一个方法调用时,RabbitMQ Consumer 不检索消息
- javascript - 我想为我的 Quiz React 应用程序启动倒数计时器(小时:分钟:秒),如何仅在选择主题时启动计时器?
- java - 在 JPA 一对多关系中分配给 NULL 的外键
- python - ModuleNotFoundError 即使在 Google Colab 中导入之后