我需要控制一些在 html 节点中单击的 div 的转换。当这些 div 带有显示“inline-block”时,它可以正常工作,但是如果我用 css3 将它们包装在列布局中,它们就不起作用(第一列除外!)
检查这个小提琴:https ://jsfiddle.net/madelavega/hjyntsob/
第一部分,用栏目布局,只有第一栏工作:点击flip再点击“i work”,注意CSS hover样式;在第二列和第三列中它不起作用。
在第二部分中,使用 display inline-block 可以正常工作。
我需要列布局,但它似乎是一个 Chrome 错误,因为它在 Firefox 上运行良好。有人知道这件事吗?
$('.flip').click(function (evt) {
$(evt.currentTarget).parents('.card').addClass('flipped');
});
$('.i-doesnt-work').click(function (evt) {
$(evt.currentTarget).parents('.card').removeClass('flipped');
})
/** Column*/
.content {
-webkit-column-count: 3;
-webkit-column-gap: 0px;
-moz-column-count: 3;
-moz-column-gap: 0px;
column-count: 3;
column-gap: 0px;
}
/* Inline-block*/
.content-di {
display: inline-block;
}
.card {
display: inline-block;
width: 150px;
height: 100px;
background: red;
margin: 3px;
-webkit-transition: -webkit-transform 1s;
-moz-transition: -moz-transform 1s;
-o-transition: -o-transform 1s;
transition: transform 1s;
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
-o-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-transform-origin: right center;
-moz-transform-origin: right center;
-o-transform-origin: right center;
transform-origin: right center;
}
.card.flipped {
-webkit-transform: translateX( -100% ) rotateY( -180deg );
-moz-transform: translateX( -100% ) rotateY( -180deg );
-o-transform: translateX( -100% ) rotateY( -180deg );
transform: translateX( -100% ) rotateY( -180deg );
}
.front {
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
position: absolute;
-o-backface-visibility: hidden;
backface-visibility: hidden;
-ms-backface-visibility: hidden;
-webkit-backface-visibility: visible;
}
.back {
webkit-transform: rotateY( 180deg );
-moz-transform: rotateY( 180deg );
-o-transform: rotateY( 180deg );
transform: rotateY( 180deg );
position: absolute;
color: #fff;
height: 100%;
top: 0px;
width: 100%;
background: #000;
-moz-backface-visibility: hidden;
-o-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-backface-visibility: visible;
}
.flip {
cursor: pointer;
}
.flipped .i-doesnt-work {
cursor: pointer;
}
.flipped .i-doesnt-work:hover {
background: blue;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>Column layout</div>
<div class="content">
<div class="card">
<div class="front">
<span class="flip">Flip</span>
</div>
<div class="back">
<span class="i-doesnt-work">I work!</span>
</div>
</div>
<div class="card">
<div class="front">
<span class="flip">Flip</span>
</div>
<div class="back">
<span class="i-doesnt-work">I work!</span>
</div>
</div>
<div class="card">
<div class="front">
<span class="flip">Flip</span>
</div>
<div class="back">
<span class="i-doesnt-work">I doesn't work!</span>
</div>
</div>
<div class="card">
<div class="front">
<span class="flip">Flip</span>
</div>
<div class="back">
<span class="i-doesnt-work">I doesn't work!</span>
</div>
</div>
<div class="card">
<div class="front">
<span class="flip">Flip</span>
</div>
<div class="back">
<span class="i-doesnt-work">I doesn't work!</span>
</div>
</div>
</div>
<div>Display: inline-block</div>
<div class="content-di">
<div class="card">
<div class="front">
<span class="flip">Flip</span>
</div>
<div class="back">
<span class="i-doesnt-work">I work!</span>
</div>
</div>
<div class="card">
<div class="front">
<span class="flip">Flip</span>
</div>
<div class="back">
<span class="i-doesnt-work">I work too!</span>
</div>
</div>
<div class="card">
<div class="front">
<span class="flip">Flip</span>
</div>
<div class="back">
<span class="i-doesnt-work">I work too!</span>
</div>
</div>
<div class="card">
<div class="front">
<span class="flip">Flip</span>
</div>
<div class="back">
<span class="i-doesnt-work">I work too!</span>
</div>
</div>
<div class="card">
<div class="front">
<span class="flip">Flip</span>
</div>
<div class="back">
<span class="i-doesnt-work">I work too!</span>
</div>
</div>
</div>