Advertisement
1xptolevitico69

CSS Hover Animation Selector Before After

Jan 7th, 2022
1,582
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.59 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>CSS Hover Animation Selector Before After</title>
  8.     <style>
  9.  
  10.  
  11. .portrait {
  12.   box-sizing: border-box;
  13.   width: 350px;
  14.   height: 450px;
  15.   border: 2px solid red;
  16.   position: absolute;
  17.   top: 50%;
  18.   left: 50%;
  19.   transform: translate(-50%, -50%);
  20.   background-color: rgba(128, 128, 128, 0.2);
  21. }
  22.  
  23. .face {
  24.   border-top: 30px solid red;
  25.   box-sizing: border-box;
  26.   width: 200px;
  27.   border-radius: 50%;
  28.   height: 300px;
  29.   padding: 80px 0;
  30.   position: absolute;
  31.   top: 50%;
  32.   left: 50%;
  33.   transform: translate(-50%, -50%);
  34.   background-color: black;
  35. }
  36.  
  37. .face:before {
  38.   box-sizing: border-box;
  39.   content: "";
  40.   width: 60px;
  41.   height: 60px;
  42.   border-radius: 50%;
  43.   background-color: white;
  44.   display: inline-block;
  45.   transform: translate(5px, -20px);
  46.   border-top: 15px solid red;
  47. }
  48.  
  49. .portrait:hover .face:before {
  50.   border-top: 60px solid red;
  51.   transition: all 0.1s linear;
  52. }
  53.  
  54. .portrait:hover .left_eye {
  55.   z-index: -1;
  56. }
  57.  
  58. .face:after {
  59.   box-sizing: border-box;
  60.   content: "";
  61.   width: 60px;
  62.   height: 60px;
  63.   border-radius: 50%;
  64.   background-color: white;
  65.   display: inline-block;
  66.   transform: translate(70px, -20px);
  67.   border-top: 15px solid red;
  68. }
  69.  
  70. .mouth {
  71.   box-sizing: border-box;
  72.   width: 90px;
  73.   height: 80px;
  74.   border-radius: 50%;
  75.   background-color: transparent;
  76.   display: inline-block;
  77.   position: absolute;
  78.   top: 150px;
  79.   left: 55px;
  80.   border-bottom: 15px solid white;
  81. }
  82.  
  83. .left_eye {
  84.   box-sizing: border-box;
  85.   border: 15px solid;
  86.   border-radius: 50%;
  87.   display: inline-block;
  88.   position: absolute;
  89.   top: 80px;
  90.   left: 25px;
  91. }
  92.  
  93. .right_eye {
  94.   box-sizing: border-box;
  95.   border: 15px solid;
  96.   border-radius: 50%;
  97.   display: inline-block;
  98.   position: absolute;
  99.   top: 80px;
  100.   left: 145px;
  101.   z-index: 1;
  102. }
  103.  
  104.     .tube {
  105.       position: absolute;
  106.       top: 10px;
  107.       left: 10px;
  108.       text-decoration: none;
  109.       background-color: red;
  110.       width: 150px;
  111.       text-align: center;
  112.       color: snow;
  113.       font-family: arial black;
  114.       padding: 5px 20px;
  115.     }
  116.  
  117.  
  118. </style>
  119. </head>
  120. <body>
  121.  
  122. <div class='portrait'>
  123.   <span class='face'>
  124.     <span class='mouth'></span>
  125.     <span class='left_eye'></span>
  126.     <span class='right_eye'></span>
  127.   </span>
  128. </div>
  129.  
  130. <a class='tube'  href='https://youtu.be/2vMDuLJIT7U'>See it on YouTube</a>
  131.  
  132.   <script></script>
  133. </body>
  134. </html>
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement