Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
234 views
in Technique[技术] by (71.8m points)

html - Canvas not hidding when CSS flip card in IOS

I'm having an issue with a flipping card that has a canvas in the front face of the card. In Chrome is working all fine, the canvas drawing hides when the card is flipped.

The problem is in safari IOS where the canvas hides only after the flipping transition effect has finished.

Here is a sample code:

var canvas = document.getElementById("myCanvas");
    var ctx = canvas.getContext("2d");
    ctx.beginPath();
    ctx.arc(95,50,40,0,2*Math.PI);
    ctx.stroke();
.card-container {
        display: grid;
    }
    
    input[type='checkbox'] {
        display: none;
    }

    .card-flip {
        display: grid;
        grid-template: 1fr / 1fr;
        grid-template-areas: "frontAndBack";
        transform-style: preserve-3d;
        -webkit-transform-style: preserve-3d;
        transition: all 0.7s ease;
    }

    .card-flip div {
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
        transform-style: preserve-3d;
        -webkit-transform-style: preserve-3d;
    }

    .front {
        grid-area: frontAndBack;
    }

    .back {
        grid-area: frontAndBack;
        transform: rotateY(-180deg);
        -webkit-transform: rotateY(-180deg);
    }

    input[type='checkbox']:checked + .card-container .card-flip {
        transform: rotateY(180deg);
    }
<html lang="es"><head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">

</head>

<body>
<div class="container">
    <div class="row">
        <input type="checkbox" id="card-1"/>
        <label class="col-md-4 card-container" for="card-1">
            <div class="card-flip">
               <div class="card front card-block">
                  <div class="card-body">
                  <p>front side<p>
                         <div>
                            <canvas id="myCanvas" width="200" height="100" style="border:1px solid #d3d3d3;">
                            Your browser does not support the canvas element.
                            </canvas>
                         </div>
                    </div>
                </div>
               <div class="card back card-block">
                  <div id="DB_card-body_back_0" class="card-body">
                    <p>Back side<p>
                  </div>
               </div>
            </div>
        </label>
    </div>
</div>

</body></html>
question from:https://stackoverflow.com/questions/65942911/canvas-not-hidding-when-css-flip-card-in-ios

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...