gpt4 book ai didi

html - HTML 中的卡片翻转程序无法正确翻转

转载 作者:行者123 更新时间:2023-11-28 17:18:54 24 4
gpt4 key购买 nike

Link to the Card Flip program!

卡片确实被翻转了,但是当它翻转时,有一瞬间的错误立即消失。我应该如何消除该错误? 我想这个错误主要发生在 backface-visibility:hidden;被使用。

*{margin:0px; padding:0px;
}
body{
background:#000;
}
.wrapper{
margin:11% 32%;
position:relative;
border:5px solid black;
width:390px;
height:360px;
perspective:800px;/*If u add some perspective to the container*/
}
.card{
width:100%;
height:100%;
position:absolute;
transition:-webkit-transform .7s cubic-bezier(0.175,0.885,0.320,1.275);/*Cubic ease giving a spring to it*/
transform-style:preserve-3d;/*2Settings...one show child elements as 3d and other as flat...so just make it always on*/
}
.card:hover{
-webkit-transform:rotateY(-180deg); /*When hovered it card flips*/
}
h2,h3{
font-family:"Arial Black", Gadget, sans-serif;
font-weight:300;
color:white;
text-transform:uppercase;
}
p{
color:white;
}
.front{
border:15px solid white;
text-align:center;
width:360px;
height:330px;
position:absolute;
backface-visibility:hidden; /*I dont wanna see your back*/
}
.back{
border:15px solid red;
text-align:center;
font-weight:400;
width:360px;
height:330px;
position:absolute;/*We dont want block ar something, we want right inside div where it was supposed to be without considering other elements*/
backface-visibility:hidden;/*I dont wanna see your back*/
-webkit-transform:rotateY(180deg);/**/
}
h2,.back{
background: #F00943;
}
h3{
text-align:left;
}
h2{
background:rgba(240, 9, 67, 0.8);
position: relative;
top:-80px;
padding:10px;
width:350px;
left:-5px;
}
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<div class="wrapper"> <!--Front & back are inside Card,Card is inside the Wrapper-->
<div class="card">
<div class="front">
<img src="http://www.dailybackgrounds.com/wp-content/uploads/2013/07/cute-cat-hd-image.jpg" height="330px" width="360px"/>
<h2>Miss Mittens</h2>
</div>
<div class="back"><br/><br/><br/>
<h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Loves:</h3><br/>
<p>Strings, cuddles, and <br/>long naps in the sun.</p><br/>
<h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dislikes:</h3><br/>
<p>Bath, things that aren't sparkly and <br/>anything reassembling work.</p>
</div>
</div>
</div>
</body>
</html>

最佳答案

添加 transform: rotateY(0deg) rotateZ(0deg) rotateX(0deg);.front

Demo Here

* {
margin: 0px;
padding: 0px;
}
body {
background: #000;
}
/*SeaseOutBack:cubic-bezier(0.175,0.885,0.320,1.275);*/

.wrapper {
margin: 11% 32%;
position: relative;
border: 5px solid black;
width: 390px;
height: 360px;
perspective: 800px;
/*If u add some perspective to the container*/
}
.card {
width: 100%;
height: 100%;
position: absolute;
transition: -webkit-transform .7s cubic-bezier(0.175, 0.885, 0.320, 1.275);
/*Cubic ease giving a spring to it*/
transform-style: preserve-3d;
/*2Settings...one show child elements as 3d and other as flat...so just make it always on*/
}
.card:hover {
-webkit-transform: rotateY(-180deg);
}
h2,
h3 {
font-family: "Arial Black", Gadget, sans-serif;
font-weight: 300;
color: white;
text-transform: uppercase;
}
p {
color: white;
}
.front {
border: 15px solid white;
text-align: center;
width: 360px;
height: 330px;
position: absolute;
backface-visibility: hidden;
transform: rotateY(0deg) rotateZ(0deg) rotateX(0deg);
}
.back {
border: 15px solid red;
text-align: center;
font-weight: 400;
width: 360px;
height: 330px;
position: absolute;
backface-visibility: hidden;
transform: rotateY(180deg);
}
h2,
.back {
background: #F00943;
}
h3 {
text-align: left;
}
h2 {
background: rgba(240, 9, 67, 0.8);
position: relative;
top: -80px;
padding: 10px;
width: 350px;
left: -5px;
}
<div class="wrapper">
<!--Front & back are inside Card,Card is inside the Wrapper-->
<div class="card">

<div class="front">
<img src="http://www.dailybackgrounds.com/wp-content/uploads/2013/07/cute-cat-hd-image.jpg" height="330px" width="360px" />
<h2>Miss Mittens</h2>
</div>
<div class="back">
<br/>
<br/>
<br/>
<h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Loves:</h3>
<br/>
<p>Strings, cuddles, and
<br/>long naps in the sun.</p>
<br/>
<h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dislikes:</h3>
<br/>
<p>Bath, things that aren't sparkly and
<br/>anything reassembling work.</p>
</div>

</div>
</div>

注意:在 Chrome 中进行了测试和工作,在 codepen 版本中,我打开了自动自动前缀器,因此您必须手动将其放入代码中。

关于html - HTML 中的卡片翻转程序无法正确翻转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28146579/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com