html - 类似于 Flipboard 的 CSS 翻转动画

标签 html css

我一直在关注本教程:https://davidwalsh.name/css-flip并遇到了一些问题。

.flip-container {
  perspective: 1000px;
}
/* flip the pane when hovered */

.flip-container:hover .flipper,
.flip-container.hover .flipper {
  transform: rotateX(180deg);
}
.flip-container,
.front,
.back {
  width: 320px;
  height: 480px;
}
/* flip speed
goes here */

.flipper {
  transition: 0.6s;
  transform-style: preserve-3d;
  position: relative;
}
/* hide back of pane during swap */

.front,
.back {
  backface-visibility: hidden;
  position: absolute;
  top: 0;
  left: 0;
}
/* front pane, placed above back */

.front {
  z-index: 2;
  /* for firefox 31 */
  transform: rotateX(0deg);
}
/* back, initially hidden pane */

.back {
  transform: rotateX(180deg);
}
.vertical.flip-container {
  position: relative;
}
.vertical .back {
  transform: rotateX(180deg);
}
.vertical.flip-container .flipper {
  transform-origin: 100% 213.5px;
  /* half of height */
}
.vertical.flip-container:hover .flipper {
  transform: rotateX(-180deg);
}
<div class="flip-container" ontouchstart="this.classList.toggle('hover');">
  <div class="flipper">
    <div class="front">
      <!-- front content -->
      <h1><center>This is the header</center></h1>
      <h4><center>Some useful info</center></h4>
      <p>
        <center>Bootstrap (currently v3.3.7) has a few easy ways to quickly get started, each one appealing to a different skill level and use case. Read through to see what suits your particular needs.Bootstrap (currently v3.3.7) has a few easy ways to quickly
          get started, each one appealing to a different skill level and use case. Read through to see what suits your particular needs.Bootstrap (currently v3.3.7) has a few easy ways to quickly get started, each one appealing to a different skill level
          and use case. Read through to see what suits your particular needs.Bootstrap (currently v3.3.7) has a few easy ways to quickly get started, each one appealing to a different skill level and use case. Read through to see what suits your particular
          needs.Bootstrap (currently v3.3.7) has a few easy ways to quickly get started, each one appealing to a different skill level and use case. Read through to see what suits your particular needs.</center>
      </p>

    </div>
    <div class="back">
      <!-- back content -->

      <h1><center>Title</center></h1>
      <h4><center>Sub</center></h4>
      <p>
        <center>Bootstrap (currently v3.3.7) has a few easy ways to quickly get started, each one appealing to a different skill level and use case. Read through to see what suits your particular needs.Bootstrap (currently v3.3.7) has a few easy ways to quickly
          get started, each one appealing to a different skill level and use case. Read through to see what suits your particular needs.Bootstrap (currently v3.3.7) has a few easy ways to quickly get started, each one appealing to a different skill level
          and use case. Read through to see what suits your particular needs.Bootstrap (currently v3.3.7) has a few easy ways to quickly get started, each one appealing to a different skill level and use case. Read through to see what suits your particular
          needs.Bootstrap (currently v3.3.7) has a few easy ways to quickly get started, each one appealing to a different skill level and use case. Read through to see what suits your particular needs.</center>
      </p>
    </div>
  </div>
</div>

一切正常,除了当我旋转图像时,它会向上翻出页面。一旦翻转,我希望内容保持在翻转前的相同位置。

enter image description here

在它翻转之后,大部分内容都会从页面上翻转:

enter image description here

另外,我最终想添加一个像翻转动画一样的翻转板扩展这个例子,我想知道这是否可能。任何教程/代码示例将不胜感激!

最佳答案

只需在“flip-containerdiv 上添加“verticalclass

关于html - 类似于 Flipboard 的 CSS 翻转动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39383516/

相关文章:

javascript - 需要两次点击的 Accordion

css - 具有绝对位置的div的宽度取决于其父级的宽度?

css - 使用 flexbox 的多列和多行布局

css - Bootstrap 最佳实践?

javascript - 作为 element.contains() 参数输入的有效属性是什么?

javascript - 在 Firefox 的 Canvas 上下文对象上使用 svg 调用 drawImage() 时出现问题

css - 无法对齐标题(容器中的 div 中的 div)

javascript - CSS 变量根伪类范围和通过 javascript 更改值

javascript - 在jQuery中如何将被 "mouseover"事件检测到的优先级赋予子元素

html - 为什么我的照片下方的段落框有一个贯穿整个页面宽度的不可见链接?