热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

需要帮助在css3中翻转div-NeedHelptoflipthedivincss3

Iamtryingtoflipthedivverticallyfromfrontsidetobacksideandthenrestoreit.ButwhenI

I am trying to flip the div vertically from front side to back side and then restore it .But when I hover instead of flipping it is folded into a thin strip.What is the problem? [The horizontal flip was working fine.Problem occured when I changed it to vertical flip]

我试着把div从正反面垂直地翻转过来,然后恢复它,但是当我悬停不翻转时,它会被折叠成一条细线。这个问题是什么?水平翻转工作正常。当我把它改成垂直翻转时出现了问题







Front Side
Back Side

1 个解决方案

#1


4  

Simply make all the rotateYs be rotateXs and make sure to add the class vertical to the container (since you have it in your CSS but not HTML)

只需将所有的rotateYs设置为rotateXs,并确保将类垂直地添加到容器中(因为在CSS中有它,而不是HTML中)

Working demo

演示工作

Changed HTML

改变了HTML

Updated CSS

更新的CSS

/* entire container, keeps perspective */
.flip-container {
    perspective: 1000px;
}

.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 {
    position: absolute;
    top: 0;
    left: 0;
    backface-visibility:hidden;
    -webkit-backface-visibility:hidden;
}

/* front pane, placed above back */
.front {
    z-index: 1;
    background-color:red;
}

/* back, initially hidden pane */
.back {
    transform: rotateX(-180deg);
    background-color:green; 
    animation: toFront 0.3s linear normal forwards;
}
.vertical.flip-container {
    position: relative;
}
.vertical.flip-container:hover .back {
    animation-delay: 0.3s;
    animation: toBack 0.3s linear normal  forwards;
}
@keyframes toBack {  
  0% {z-index:0;}
  100% {z-index:1;}
}
@keyframes toFront {
  0% {z-index:1;}
  100% {z-index:0;}
}
.vertical.flip-container .flipper {
    transform-origin: 100% 240px; /* half of height */
}

.vertical.flip-container:hover .flipper {
    transform: rotateX(-180deg);
}

I added full functionality using CSS3 animations as well

我还使用CSS3动画添加了完整的功能


推荐阅读
author-avatar
乐天派jiao2502901101
这个家伙很懒,什么也没留下!
Tags | 热门标签
RankList | 热门文章
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有