CSS: transform transition
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> img { width: 200px; border: 3px solid tan; border-radius: 50%; transition: all 1s ease-in-out 0.5s; } img:hover { transform: rotate(360deg); } </style> </head> <body> <div><img src="/images/pic.jpg" alt=""></div> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> div{ position: relative; width: 300px; height: 40px; border: 1px solid purple; } div::after{ content: ''; position: absolute; top: calc(40px / 2 - 10px); right: 10px; width: 10px; height: 10px; border-right: 1px solid peru; border-bottom: 1px solid peru; transform: rotate(45deg); transition: all 1s ease-in-out 0.5s; } div:hover::after{ transform: rotate(225deg); top: 20px; } </style> </head> <body> <div></div> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> div{ width: 200px; height: 200px; background-color: palegoldenrod; margin: 100px auto; transition: all 1s ease-in-out .5s; /* transform-origin: left bottom; */ transform-origin: 50px 50px; } div:hover{ transform: rotate(360deg); } </style> </head> <body> <div></div> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> div{ overflow: hidden; position: relative; width: 200px; height: 200px; border: 1px solid peru; margin: 100px auto; } div::before{ content: '::before'; position: absolute; width: 100%; height: 100%; background-color:rosybrown; transform: rotate(180deg); transform-origin: left bottom; transition: all 1s ease-in-out; } div:hover::before{ transform: rotate(0deg); } </style> </head> <body> <div></div> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> div { width: 200px; height: 200px; background-color: aliceblue; margin: 300px auto; transition: all 1s ease-in-out .5s; } div:hover { /* transform: scale(2,2); */ transform: scale(0.5, 0.5); transform-origin: left bottom; } </style> </head> <body> <div></div> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> div{ overflow: hidden; float:left; width: 200px; height: 200px; margin:200px 50px; } div img{ transition: all 0.5s ease-in-out; } div img:hover{ transform: scale(1.2,1.2); } </style> </head> <body> <div><a href="#"><img src="/images/pic.jpg" alt=""></a></div> <div><a href="#"><img src="/images/pic.jpg" alt=""></a></div> <div><a href="#"><img src="/images/pic.jpg" alt=""></a></div> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> li{ float: left; width: 30px; height: 30px; margin: 20px; border: 1px solid purple; border-radius: 50%; list-style: none; line-height: 30px; text-align: center; cursor: copy; transition: all 0.5s ease-in-out; } li:hover{ transform: scale(1.3); } </style> </head> <body> <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> <li>7</li> </ul> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> div{ width: 200px; height: 200px; background-color: palegoldenrod; transition: all 1s ease-in-out; } div:hover{ transform: translate(250px,50px) rotate(180deg) scale(1.3); } </style> </head> <body> <div></div> </body> </html>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了