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>

 

posted @ 2022-02-02 21:12  ascertain  阅读(26)  评论(0编辑  收藏  举报