css - 如何在悬停效果上创建 css translateY

标签 css hover transform mousehover

我想创建一个我知道一定可行的 CSS 悬停效果,但我就是无法解决它,想知道是否有一些明亮的 Spark 能够为我指明正确的方向!

See this image here showing what I would like to achieve

因此显示了图像上方的 div 中的一些文本,但是当您将鼠标悬停在图像/文本 div 上时,内容以平滑的方式向上移动

这会与 -webkit-transition translateY 元素一起使用吗?

提前感谢您提供的任何建议或指南! 亚当

最佳答案

要翻译吗...没有,你可以通过定位来做到这一点。

可以说,使用翻译方法可能对性能更好。

.one {
  width: 300px;
  height: 300px;
  margin: 50px auto;
  overflow: hidden;
  background-color: #663399;
  position: relative;
}
.two {
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  position: absolute;
  top: 80%;
  transition: top .5s ease;
  color: white
}
.one:hover .two {
  top: 0;
}
p {
  margin: 0;
  padding: 1em;
  color: #ffffff;
}
<div class="one">
  <div class="two">
    <h2>Content</h2>
    <p>
      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellat aut provident quasi veniam earum officiis vero odit doloribus blanditiis? Veritatis ab repudiandae non labore eligendi quasi officia quibusdam accusamus sit harum quisquam soluta tempore,
      odio at, iste animi numquam officiis, quam ipsa! Fuga suscipit temporibus perspiciatis explicabo ipsa laudantium aut.
    </p>
  </div>
</div>

关于css - 如何在悬停效果上创建 css translateY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36794634/

相关文章:

css - 如何让 twitter-bootstrap 导航栏子项在小屏幕上折叠/展开?

html - 尝试使其成为 3 col 时,网格布局 float hack 不起作用

css - 背景颜色不改变下拉菜单和导航栏

CSS 悬停图像

css - 当 CSS 看似相同时,到哪里寻找差异呢?

html - `pointer-events: none;` 不适用于 Edge 中的 iframe

css - 没有循环悬停的视频

javascript - Raphael JS 翻转图像

html - IE10+ 嵌套 3d 变换内部溢出 :auto are brake :hover behaviour

html - Tinymce - 闪烁的光标隐藏在转换后的(缩放的)contenteditable Div 上