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
242 views
in Technique[技术] by (71.8m points)

html - Backface-visibility:hidden; not working properly

I am too weak in designing, so practicing some css But i am stucked on backface-visibility:hidden; but don't know why its not working, its working on an class but not in another class while i have coded the attribute with both classes at a time can anyone explain this ? here is my codes

body{
    background: #292929;
    align-items: center;
    display: flex;
    justify-content: center;
    font-family: arial;
    height: 100vh;
}
.cardBox{
    perspective: 500px;
    margin: 15px;
}
.card{
    position: relative;
    width: 150px;
    height: 150px;
    background: #fff;
    transform-style: preserve-3d;
    transition: .5s ease;
    box-shadow: 0 30px 30px rgba(0, 0, 0, .5);
}
.facebook{
    background: #3b5998;
}
.twitter{
    background: #00aced;
}
.googleplus{
    background: #dd4b39;
}
.card-front, 
.card-back{
    position: absolute;
    top: 0;
    left: 0;
    width: 150px;
    height: 150px;
    color: #fff;
    backface-visibility: hidden;
    justify-content: center;
    align-items: center;
    display: flex;
}
.card-front{
    font-size: 40px;
}
.card-back{
    font-size: 30px;
}
.cardBox:hover .card{
    transform: rotateY(180deg);
}
.card-back{
    transform: rotateY(180deg);
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>3d card flip animation - css tutorial - Pure Css Social Media Buttons</title>
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
    <div class="cardBox">
        <div class="card facebook">
            <div class="card-front">
                <i class="fa fa-facebook-f" aria-hidden="true"></i>
            </div>
            <div class="card-back">Facebook</div>
        </div>
    </div>
    <div class="cardBox">
        <div class="card twitter">
            <div class="card-front">
                <i class="fa fa-twitter" aria-hidden="true"></i>
            </div>
            <div class="card-back">Twitter</div>
        </div>
    </div>
    <div class="cardBox">
        <div class="card googleplus">
            <div class="card-front">
                <i class="fa fa-google-plus" aria-hidden="true"></i>
            </div>
            <div class="card-back">Google+</div>
        </div>
    </div>
</body>
</html>
question from:https://stackoverflow.com/questions/66058327/backface-visibilityhidden-not-working-properly

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

1 Reply

0 votes
by (71.8m points)

body {
    background: #292929;
    align-items: center;
    display: flex;
    justify-content: center;
    font-family: arial;
    height: 100vh;
}
.cardBox {
    perspective: 500px;
    margin: 15px;
}
.card {
    position: relative;
    width: 150px;
    height: 150px;
    background: #fff;
    transform-style: preserve-3d;
    transition: 0.5s ease;
    box-shadow: 0 30px 30px rgba(0, 0, 0, 0.5);
}
.facebook {
    background: #3b5998;
}
.twitter {
    background: #00aced;
}
.googleplus {
    background: #dd4b39;
}
.card-front,
.card-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 150px;
    height: 150px;
    color: #fff;
    backface-visibility: hidden;
    justify-content: center;
    align-items: center;
    display: flex;
}
.card-front {
    font-size: 40px;
    transform: rotateY(0deg);
}
.card-back {
    font-size: 30px;
    transform: rotateY(-180deg);
}
.cardBox:hover .card {
    transform: rotateY(180deg);
}
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>
            3d card flip animation - css tutorial - Pure Css Social Media
            Buttons
        </title>
        <link rel="stylesheet" href="style.css" />
        <link
            rel="stylesheet"
            href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
        />
    </head>
    <body>
        <div class="cardBox">
            <div class="card facebook">
                <div class="card-front">
                    <i class="fa fa-facebook-f" aria-hidden="true"></i>
                </div>
                <div class="card-back">Facebook</div>
            </div>
        </div>
        <div class="cardBox">
            <div class="card twitter">
                <div class="card-front">
                    <i class="fa fa-twitter" aria-hidden="true"></i>
                </div>
                <div class="card-back">Twitter</div>
            </div>
        </div>
        <div class="cardBox">
            <div class="card googleplus">
                <div class="card-front">
                    <i class="fa fa-google-plus" aria-hidden="true"></i>
                </div>
                <div class="card-back">Google+</div>
            </div>
        </div>
    </body>
</html>

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

...