【问题标题】:Flipcards ... broken on mobileFlipcards ...在移动设备上损坏
【发布时间】:2018-07-29 08:42:44
【问题描述】:

我一直在制作一些要放在网站上的翻转卡片(使用 bootstrap 4 和 jQuery),并且在桌面上看起来一切正常,但是当我在移动设备上测试它时,事情变得奇怪,背面卡片消失,正面卡片得到翻转。

我已经在代码中说明了一段时间,并试图解决这个问题,但没有运气,所以我将它放入了一个 codepen 并决定寻求一些帮助。

我猜这很明显,但代码在这里https://codepen.io/magical1/pen/paaNmB

我想有问题的代码在这里

@media not all,
not all {
    .front,
    .back {}
    .back {
        visibility: hidden;
    }
    .front {
        z-index: 4;
    }
    .card-container:not(.manual-flip):hover .back,
    .card-container.manual-flip.hover .back {
        z-index: 5;
        visibility: visible;
    }
}

【问题讨论】:

  • not all, not all 应该是?
  • 如果我将其更改为 @media screen@media screen,screen 我会收到 .card .front 反向加载...不知道如何解决这个问题?
  • 好吧,事实证明,将它设置为 all 而不是 not all 并删除我在父 div 上的额外 .hover 类解决了这个问题,我讨厌你离得太近对于某事,无论您尝试什么,都看不到错误...感谢@RokoC.Buljan ...这只是我需要的轻推:)
  • 很高兴你成功了! :)
  • @RokoC.Buljan 事实证明,虽然它在 codepen 中有效,但在实时站点中无效,现在我没有显示背面,我可以在其他图层下方看到它,但无法显示

标签: jquery bootstrap-4 responsive


【解决方案1】:

问题似乎出在苹果设备上的 transform-style 上。

Codepen:https://codepen.io/YasirKamdar/pen/oEEZwJ

更新 CSS 如下:

body {
    margin-top: 60px;
    font-size: 14px;
    background-color: rgb(226, 239, 252);
}

.card-container {
    perspective: 800px;
    margin-bottom: 30px;
}

.card-container:not(.manual-flip):hover .card,
.card-container.hover.manual-flip .card {
    transform: rotateY(180deg);
}

.card-container.static:hover .card,
.card-container.static.hover .card {
    transform: none;
}

.card {
    transition: transform 0.5s;
    /*transform-style: preserve-3d;*/
    position: relative;
    border: none;
}

.front,
.back {
    position: absolute;
    top: 0px;
    left: 0px;
}

.front {
    z-index: 2;
}

.back {
    transform: rotateY(180deg);
    z-index: 3;
}

.btn-simple{
    background: white;
    border-radius: 50px;
}

btn-simple i{
    font-size:13px;
}

.back .btn-simple {
    position: absolute;
  right: 4px;
    top: 4px;
  width 26px;
}

.card {
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    border-bottom-right-radius: 24px;
    border-bottom-left-radius: 24px;
    color: rgb(68, 68, 68);
}

.grad1 .front,
.grad1 .back {
    background-image: linear-gradient(141deg, rgb(114, 178, 204) 0%, rgb(106, 150, 196) 34%, rgb(88, 104, 189) 66%, rgb(88, 104, 219) 100%);
}

.grad2 .front,
.grad2 .back {
    background-image: linear-gradient(135deg, rgb(253, 139, 165) 0%, rgb(193, 71, 111) 100%);
}

.grad3 .front,
.grad3 .back {
    background-image: linear-gradient(141deg, rgb(228, 190, 143) 0%, rgb(228, 158, 158) 28%, rgb(209, 105, 164) 100%);
}

.card-container,
.front,
.back {
    width: 100%;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    border-bottom-right-radius: 24px;
    border-bottom-left-radius: 24px;
    min-height: 420px !important;
}

@media all, all {
    .front,
    .back {}
    .back {
        visibility: hidden;
    }
    .front {
        z-index: 4;
    }
    .card-container:not(.manual-flip):hover .back,
    .card-container.manual-flip.hover .back {
        z-index: 5;
        visibility: visible;
    }
}

【讨论】:

  • 感谢一百万解决了问题,对于延迟回复您有关此问题深表歉意!这是完美的解决方案:)
猜你喜欢
  • 2021-09-04
  • 1970-01-01
  • 2013-07-27
  • 1970-01-01
  • 1970-01-01
  • 2012-05-07
  • 1970-01-01
  • 1970-01-01
  • 2021-11-03
相关资源
最近更新 更多