html - 部分不从页面下移至顶部

标签 html css

我正在尝试对从底部页面到顶部的部分内的段落进行动画处理,但它不起作用。

如何解决这个问题?

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>

最佳答案

请添加“position:absolute;”到“span p”样式。

底部值必须包含“px”。

body {
  background: rgb(196, 56, 56);
  height: 100%;
  width: 100%;
}

section {
  position: relative;
}
section p {
    position: absolute;
  color: rgb(235, 197, 31);
  animation: 1s slid;
}

@keyframes slid {
  0% {
    bottom: -100px;
    opacity: 0;
  }
  100% {
    bottom: 0;
    opacity: 1;
  }
}
<body>
    <section>
        <p>I'm YASER</p>
    </section>
</body>

关于html - 部分不从页面下移至顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69426991/

相关文章:

PHP MySQL - 如何每周随机选择项目?

javascript - 当元素被放入其中时,使可放置的 div 展开。使用可拖动的 jquery ui

html - div 对齐方式 - % 宽度

Javascript条件

javascript - 单击更改下一个 TD 表

html - 如何在底部区域放置菜单?

html - CSS 背景图像可以将其父 div 填充到左侧而不是右侧吗?

html - 几乎全屏标题问题

javascript - 同位素等高行

javascript - 确定元素是否将通过 CSS3 过渡设置动画