CSS旋转信息卡正在闪烁



我有一些我想找出的纯HTML/CSS -

悬停在卡上应执行翻转效果。效果有效,但是如果您过快或以怪异的角度碰到它,它将产生一种"口吃"。我正在尝试修复它,以便无论如何它都是无缝的。

似乎是当光标进入卡容器外面时发生的问题,因为盒子正在缩小并再次扩展以创建翻转效果。

任何想法如何解决?

https://codepen.io/mttmrn/pen/zgzkjj

HTML:
<body>
  <!-- 
            This is where the cards start
        -->
  <div class="card-container">
    <div class="card">
      <div class="card-front">
        <img src="./img/cool-background.png" alt="background" class="card-img">
        <ul class="card-text">
          <li>React | Redux</li>
          <li>NodeJS</li>
          <li>JavaScript</li>
        </ul>
      </div>
      <div class="card-back">
        <ul class="card-text">
          <li>hello</li>
          <li>twice</li>
        </ul>
      </div>

CSS:
* {
  margin: 0px;
  padding: 0px;
  box-sizing: border-box;
}
body {
  font-family: "Poppins", sans-serif;
  background: rgb(250, 224, 30);
}
.card-container {
  display: flex;
  margin-top: 12%;
  margin-left: 15%;
  margin-right: 15%;
  justify-content: space-evenly;
  text-align: center;
  flex-wrap: wrap;
}
.card {
  width: 275px;
  height: 350px;
  border: 4px solid black;
  margin-top: 50px;
  border-radius: 2px;
  -webkit-box-shadow: 4px 4px 10px 0px rgba(0, 0, 0, 0.75);
  -moz-box-shadow: 4px 4px 10px 0px rgba(0, 0, 0, 0.75);
  box-shadow: 3px 3px 6px 0px rgba(0, 0, 0, 0.75);
  transform-style: preserve-3d;
  transition: transform 1s;
}
.card:hover {
  transform: rotateY(180deg);
}
.card-front {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
}
.card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  transform: rotateY(180deg);
}
.card-back {
  background: wheat;
}
.card-text {
  list-style: none;
  margin: 20px 50px 0px 50px;
  line-height: 40px;
}
.card-text li:not(:last-child) {
  border-bottom: 1px solid #0004;
}
.card-img {
  height: 150px;
  width: 268px;
  -webkit-clip-path: polygon(0 0, 100% 0, 100% 68%, 0 100%);
  clip-path: polygon(0 0, 100% 0, 100% 68%, 0 100%);
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.card-front:nth-child(1) {
  animation: fadeIn 1.5s 0.3s backwards;
}
.card-front:nth-child(2) {
  animation: fadeIn 1.5s 0.6s backwards;
}
.card-front:nth-child(3) {
  animation: fadeIn 1.5s 0.9s backwards;
}
.card-front:nth-child(4) {
  animation: fadeIn 2s 1.2s backwards;
}
.card-front:nth-child(5) {
  animation: fadeIn 2s 1.5s backwards;
}
.card-front:nth-child(6) {
  animation: fadeIn 2s 1.8s backwards;
}

当悬停在盘旋上时,动画应保持光滑,并应拨动,直到光标离开卡片。

感谢您上传笔。我看了一个人,并在以下内容上添加了一个示例(例如,将杂物减少到1张卡(:

* {
  margin: 0px;
  padding: 0px;
  box-sizing: border-box;
}
body {
  font-family: "Poppins", sans-serif;
  background: rgb(250, 224, 30);
}
.card-container {
  display: flex;
  margin-left: 15%;
  margin-right: 15%;
  justify-content: space-evenly;
  text-align: center;
  flex-wrap: wrap;
}
.box {
  perspective: 1000px;
}
.card {
  width: 275px;
  height: 350px;
  border: 4px solid black;
  margin-top: 50px;
  border-radius: 2px;
  -webkit-box-shadow: 4px 4px 10px 0px rgba(0, 0, 0, 0.75);
  -moz-box-shadow: 4px 4px 10px 0px rgba(0, 0, 0, 0.75);
  box-shadow: 3px 3px 6px 0px rgba(0, 0, 0, 0.75);
  transform-style: preserve-3d;
  transition: 1s ease;
}
.box:hover .card {
  transform: rotateY(180deg);
}
.card-front, .card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
}
.card-back {
  background: wheat;
  transform: rotateY(180deg);
}
.card-text {
  list-style: none;
  margin: 20px 50px 0px 50px;
  line-height: 40px;
}
.card-text li:not(:last-child) {
  border-bottom: 1px solid #0004;
}
.card-img {
  height: 150px;
  width: 268px;
  -webkit-clip-path: polygon(0 0, 100% 0, 100% 68%, 0 100%);
  clip-path: polygon(0 0, 100% 0, 100% 68%, 0 100%);
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.card-front:nth-child(1) {
  animation: fadeIn 1.5s 0.3s backwards;
}
.card-front:nth-child(2) {
  animation: fadeIn 1.5s 0.6s backwards;
}
.card-front:nth-child(3) {
  animation: fadeIn 1.5s 0.9s backwards;
}
.card-front:nth-child(4) {
  animation: fadeIn 2s 1.2s backwards;
}
.card-front:nth-child(5) {
  animation: fadeIn 2s 1.5s backwards;
}
.card-front:nth-child(6) {
  animation: fadeIn 2s 1.8s backwards;
}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <script defer src="https://use.fontawesome.com/releases/v5.9.0/js/all.js" integrity="sha384-7Gk1S6elg570RSJJxILsRiq8o0CO99g1zjfOISrqjFUCjxHDn3TmaWoWOqt6eswF" crossorigin="anonymous">
  </script>
  <link href="https://fonts.googleapis.com/css?family=Poppins:400,500&display=swap" rel="stylesheet">
  <link rel="stylesheet" href="./style.css" />
</head>
<body>
  <!-- 
            This is where the cards start
        -->
  <div class="card-container">
    <div class="box">
    <div class="card">
      <div class="card-front">
        <img src="./img/cool-background.png" alt="background" class="card-img">
        <ul class="card-text">
          <li>React | Redux</li>
          <li>NodeJS</li>
          <li>JavaScript</li>
        </ul>
      </div>
      <div class="card-back">
        <ul class="card-text">
          <li>hello</li>
          <li>twice</li>
        </ul>
      </div>
    </div>
    </div>
  </div>
  <!--
            Card End
        -->
</body>
</html>

本质上,我已经添加了一个盒装包装器,并将转换规则添加到了,同时清理前后类中的少量共享代码,以避免对转换的卡类"战斗"。我还会看一下转换代码并放入一些webkit位,ala:

transform: rotateY(180deg);
-webkit-transform: ...

让我知道您在这里是否不了解任何东西,还是我可以进一步帮助您。

我希望这就是您要寻找的。因此,我要做的就是在每个卡div周围添加一个卡片编织div并在该卡上使用悬停,以便即使实际卡旋转时,光标的位置都可以旋转

.wrap-card:hover .card{
   transform: rotateY(180deg);
}

这是片段

* {
  margin: 0px;
  padding: 0px;
  box-sizing: border-box;
}
body {
  font-family: "Poppins", sans-serif;
  background: rgb(250, 224, 30);
}
.card-container {
  display: flex;
  margin-top: 12%;
  margin-left: 15%;
  margin-right: 15%;
  justify-content: space-evenly;
  text-align: center;
  flex-wrap: wrap;
}
.card {
  width: 275px;
  height: 350px;
  border: 4px solid black;
  margin-top: 50px;
  border-radius: 2px;
  -webkit-box-shadow: 4px 4px 10px 0px rgba(0, 0, 0, 0.75);
  -moz-box-shadow: 4px 4px 10px 0px rgba(0, 0, 0, 0.75);
  box-shadow: 3px 3px 6px 0px rgba(0, 0, 0, 0.75);
  transform-style: preserve-3d;
  transition: transform 1s;
}
.card-wrap:hover .card {
  transform: rotateY(180deg);
}
.card-front {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
}
.card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  transform: rotateY(180deg);
}
.card-back {
  background: wheat;
}
.card-text {
  list-style: none;
  margin: 20px 50px 0px 50px;
  line-height: 40px;
}
.card-text li:not(:last-child) {
  border-bottom: 1px solid #0004;
}
.card-img {
  height: 150px;
  width: 268px;
  -webkit-clip-path: polygon(0 0, 100% 0, 100% 68%, 0 100%);
  clip-path: polygon(0 0, 100% 0, 100% 68%, 0 100%);
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.card-front:nth-child(1) {
  animation: fadeIn 1.5s 0.3s backwards;
}
.card-front:nth-child(2) {
  animation: fadeIn 1.5s 0.6s backwards;
}
.card-front:nth-child(3) {
  animation: fadeIn 1.5s 0.9s backwards;
}
.card-front:nth-child(4) {
  animation: fadeIn 2s 1.2s backwards;
}
.card-front:nth-child(5) {
  animation: fadeIn 2s 1.5s backwards;
}
.card-front:nth-child(6) {
  animation: fadeIn 2s 1.8s backwards;
}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <script defer src="https://use.fontawesome.com/releases/v5.9.0/js/all.js" integrity="sha384-7Gk1S6elg570RSJJxILsRiq8o0CO99g1zjfOISrqjFUCjxHDn3TmaWoWOqt6eswF" crossorigin="anonymous">
  </script>
  <link href="https://fonts.googleapis.com/css?family=Poppins:400,500&display=swap" rel="stylesheet">
  <link rel="stylesheet" href="./style.css" />
</head>
<body>
  <!-- 
            This is where the cards start
        -->
  <div class="card-container">
    <div class="card-wrap">
      <div class="card">
      <div class="card-front">
        <img src="./img/cool-background.png" alt="background" class="card-img">
        <ul class="card-text">
          <li>React | Redux</li>
          <li>NodeJS</li>
          <li>JavaScript</li>
        </ul>
      </div>
      <div class="card-back">
        <ul class="card-text">
          <li>hello</li>
          <li>twice</li>
        </ul>
      </div>
    </div>
    </div>
    <div class="card-wrap">
      <div class="card">
      <div class="card-front">
        <img src="./img/cool-background.png" alt="background" class="card-img">
        <ul class="card-text">
          <li>React | Redux</li>
          <li>NodeJS</li>
          <li>JavaScript</li>
        </ul>
      </div>
      <div class="card-back">
        <ul class="card-text">
          <li>hello</li>
          <li>twice</li>
        </ul>
      </div>
    </div>
    </div>
 
  </div>
  <!--
            Card End
        -->
</body>
</html>

最新更新