HTML / CSS翻转卡可在台式机上使用,但不能在移动设备上使用

时间:2020-07-17 17:23:01

标签: html css hover css-animations

我正在帮助一个基本的html / css网站的朋友,我们在设置翻页卡效果方面遇到了麻烦。

您可以在这里看到它:https://www.fragranceadvisorjobs.com/ 悬停在中间部分的瓷砖会翻转,并显示有关品牌的信息。 在台式机上和使用Chrome的响应式查看器似乎都可以正常工作。

但是,当我在移动设备(ios)上访问网站时,它会产生翻转效果,但不会在卡背面显示内容。

.flip-card {
  background-color: transparent;
  width: 32%;
  display: inline-block;
  height: 200px;
  perspective: 1000px;
  padding-left: 1px;
  padding-right: 1px;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s;
  transform-style: preserve-3d;

}

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

.flip-card-front, .flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
}

.flip-card-front {
  color: black;
}

.flip-card-back {
  background-color: #000;
  color: #fff;
  transform: rotateY(180deg);
}

@media (max-width: 768px) {
  .flip-card {
        height: 180px;
    }
}

@media (max-width: 425px) {
    .flip-card {
        width: 98%;
        height: 150px;
    }
}
 <div class="flip-card">
  <div class="flip-card-inner" style="background-color: #000">
    <div class="flip-card-front">
     <div class="logo_rowthird" ><img src="https://www.fragranceadvisorjobs.com/images/logos/lorealwhite.svg" alt="atelier" style="max-height: 80px;" class="shadow"></div></div>
     <div class="flip-card-back">
      <h1>L'Oreal Luxe</h1> 
       <p>“L’Oréal Luxe opens a unique world of beauty. Its international brands incarnate all the facets of elegance and refinement in three major specializations: skin care, make-up and perfume.</p>
    </div>
     </div></div>

我已经使用用于此设置的编码创建了一支密码笔 https://codepen.io/MarioDidIt/pen/rNxQVaw

奇怪的是,代码笔中的代码与网站上的内容完全相同,并且可以在网站上正常工作,但是在代码笔中,它在背面没有任何显示。我猜代码笔的读取方式与ios浏览器的读取方式相同。

有人知道我可以解决此问题吗?任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:2)

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
  font-family: Arial, Helvetica, sans-serif;
}

.flip-card {
  background-color: transparent;
  width: 300px;
  height: 300px;
  perspective: 1000px;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s;
  transform-style: preserve-3d;
  box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
}

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

.flip-card-front, .flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.flip-card-front {
  background-color: #bbb;
  color: black;
}

.flip-card-back {
  background-color: #2980b9;
  color: white;
  transform: rotateY(180deg);
}
</style>
</head>
<body>

<h1>Card Flip with Text on Back</h1>
<h3>Hover over the image on a desktop to see the back</h3>
<h3>Click on the image on mobile to see the back</h3>

<div class="flip-card">
  <div class="flip-card-inner">
    <div class="flip-card-front">
      <img src="https://via.placeholder.com/300" alt="Avatar" style="width:300px;height:300px;">
    </div>
    <div class="flip-card-back">
      <h1>Content Header</h1> 
      <p>Content Part I</p> 
      <p>Content Part II</p>
    </div>
  </div>
</div>

</body>
</html>

希望对您有所帮助。 :-)