CSS レビュー 4

マウスで写真を360度回転させてください

    <style>
        img {
    
    
            width: 150px;
            border-radius: 50%;
            border: 5px solid pink;
            /* 过度写到本身上,谁做动画给谁加 */
            transition: all 0.5s;
        }
        
        img:hover {
    
    
            transform: rotate(360deg);
        }
    </style>

<body>
    <!-- 效果:鼠标放上去旋转360度 -->
    <img src="pic.jpg" alt="">
</body>

最終的な効果:
写真の説明を追加してください

画像拡大事例

   <style>
        div {
    
    
            overflow: hidden;
            float: left;
            margin: 10px;
        }
        
        div img {
    
    
            transition: all 0.5s;
        }
        
        div img:hover {
    
    
            transform: scale(1.1);
        }
    </style>


<body>
    <div>
        <a href="#"><img src="scale.jpg" alt=""></a>
    </div>
    <div>
        <a href="#"><img src="scale.jpg" alt=""></a>
    </div>
    <div>
        <a href="#"><img src="scale.jpg" alt=""></a>
    </div>
</body>

最終的な効果:
写真の説明を追加してください

ページネーションボタン

   <style>
        ul li {
    
    
            float: left;
            width: 30px;
            height: 30px;
            border: 1px solid green;
            margin: 10px;
            border-radius: 50%;
            line-height: 30px;
            text-align: center;
            list-style: none;
            transition: all 0.4s;
            cursor: pointer;
        }
        
        li:hover {
    
    
            transform: scale(1.2);
        }
    </style>
</head>

<body>
    <div>
        <ul>
            <li>1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
            <li>6</li>
            <li>7</li>
        </ul>
    </div>
</body>

最終的な効果:
写真の説明を追加してください

アニメーション

アニメーションの作成は、次の 2 段階のプロセスです。

  1. 最初にアニメーションを定義する
  2. アニメーションを再利用 (呼び出し)

キーフレームを使用してアニメーションを定義する (クラス セレクターの定義と同様)

@keyframes 动画名称 {
    
    
   0%{
    
    
        width:100px;
   }  
   100%{
    
    
        width:200px;
   }
}

分割することもできます

@keyframes move
0%{
    
    
transform:translate(0,0);
}
25%{
    
    
transform:translate(1000px,0)
}
50%{
    
    
transform:translate(1000px,500px);
)
75%(
transform:translate(0,500px);
)
100%(
transform:translate(0,0);
)

要素はアニメーションを使用します

div {
    
    
       width: 200px;
       height: 200px;
       background-color: aqua;
       margin: 100px auto;
       /* 调用动画 */
       animation-name: 动画名称;
       /* 持续时间 */
       animation-duration: 持续时间;
    }

おすすめ

転載: blog.csdn.net/qq_40992225/article/details/129069721