简体   繁体   English

CSS 3D转换只有一半可点击

[英]CSS 3D Transform Only Half Clickable

I'm trying to create a flippable card that flips on click. 我正在尝试创建一种可翻转的卡片,该卡片在点击时会翻转。 The card is default face down, and for some reason, only the right half of the card is clickable. 该卡默认是面朝下的,由于某种原因,只能单击卡的右半部分。 I'm trying to make the whole card able to click and flip. 我正在尝试使整个卡片都可以单击和翻转。 JSFiddle below for example. 下面以JSFiddle为例。

http://jsfiddle.net/aa3Lc/ http://jsfiddle.net/aa3Lc/

.card {
    background: #fff;
    cursor: pointer;
    display: inline-block;
    font-size: 1.5em;
    font-weight: 800;
    line-height: 2em;
    border: 2px solid #000;
    height: 50px;
    margin: 5px 0 ;
    text-align: center;
    width: 38px;

    border-radius: 3px;
    -webkit-transform: perspective(1000px) rotateY(180deg);
    -moz-transform: perspective(1000px) rotateY(180deg);
    transform: perspective(1000px) rotateY(180deg);
    -webkit-transform-style: preserve-3d;
    -moz-transform-style: preserve-3d;
    transition: all 0.2s linear;
}
.card.active {
    -webkit-transform: perspective(1000px) rotateY(0deg);
    -moz-transform: perspective(1000px) rotateY(0deg);
    transform: perspective(1000px) rotateY(0deg);
}
.card .card-front {
    display: block;
    width: 38px;
    height: 100%;
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
}
.card .card-back {
    cursor: pointer;
    display: block;
    width: 38px;
    height: 100%;
    box-sizing: border-box;
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
}

Change -webkit-transform: perspective(1000px) rotateY(180deg); 更改-webkit-transform: perspective(1000px) rotateY(180deg); in .card to .card

-webkit-transform: perspective(1000px) rotateY(180deg) translateZ(-1px);

to fix your issue. 解决您的问题。 Demo 演示

Not 100% sure why you have perspective(1000px) for each one as well... I'd put perspective: 1000px; 不能100%确定为什么还要为每个perspective(1000px)都设置perspective(1000px) perspective: 1000px; below the transform on .card and remove all the rest .card上的转换下方,并删除所有其余的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM