8.HTML+CSS——鼠标经过图片(稍惊悚)翻转特效

8.HTML+CSS——鼠标经过翻转图片特效

图片稍惊悚


HTML:


<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>图片翻转title>
    <link rel="stylesheet" href="css/5-31.css">
head>

<body>
    <div class="box">
        <div class="front">
            <img src="images/ct81.jpg" alt="">
        div>
        <div class="back">
            <img src="images/ct41.jpg" alt="">
        div>
    div>
body>

html>

css:

body {
    perspective: 400px;
    margin: 0;
    padding: 0;
    background-color: #1f4662;
}

.box {
    position: relative;
    width: 400px;
    height: 400px;
    margin: 100px auto;
    transition: all .4s;
    /* 让背面的紫色盒子保留立体空间 给父级添加的 */
    transform-style: preserve-3d;
}

.box:hover {
    transform: rotateY(180deg);
}

.front,
.back,
img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.front {
    z-index: 1;
}

.back {
    /* 像手机一样 背靠背 旋转 */
    transform: rotateY(180deg);
}

不定时更

你可能感兴趣的:(前端案例合集,css)