Advertisement
powylv

[template] box shake into scrollbox onclick

Mar 22nd, 2023 (edited)
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.96 KB | None | 0 0
  1. <!DOCTYPE HTML><meta charset="utf-8" /><meta name="viewport" content="width=device-width,initial-scale=1" />
  2.  
  3. <style>
  4. @import url('https://fonts.googleapis.com/css2?family=Bellota:wght@700&display=swap');
  5. @font-face {
  6. font-family: rosalie;
  7. src: url(https://dl.dropbox.com/s/xqlz6p59syect4a/rosalie.regular.otf);
  8. }
  9.  
  10. html, body {
  11. height: 100%;
  12. display: flex;
  13. align-items: center;
  14. justify-content: center;
  15. }
  16.  
  17. #container {
  18. box-sizing: border-box;
  19. background: #AFA5C9;
  20. position: relative;
  21. height: 19rem;
  22. width: 19rem;
  23. box-shadow: rgba(50, 50, 93, 0.6) 0px 50px 100px -20px, rgba(0, 0, 0, 0.5) 0px 30px 60px -30px, rgba(66, 10, 25, 0.65) 0px -2px 6px 0px inset;
  24. padding: 0.7rem;
  25. border-radius: 0.8rem;
  26. }
  27. #container:hover {
  28. animation: shake 1s, blur 1s;
  29. transition: all 1s ease-in-out;
  30. transition-timing-function: cubic-bezier(0.1, 0.8, 0.9, 0.1);
  31. }
  32.  
  33. #figure {
  34. position: relative;
  35. height: 100%;
  36. width: 100%;
  37. border-radius: 0.5rem;
  38. pointer-events: none;
  39. }
  40.  
  41. #container, #box, #title {
  42. margin-right: auto;
  43. margin-left: auto;
  44. left: 0;
  45. right: 0;
  46. }
  47.  
  48. #title, #box, #left-wing, #right-wing {
  49. position: absolute;
  50. }
  51.  
  52. #box {
  53. width: 70%;
  54. height: 50%;
  55. overflow: auto;
  56. background: #AFA5C9CF;
  57. font: 0.84rem 'bellota', cursive;
  58. color: white;
  59. padding: 0.7rem;
  60. display: none;
  61. bottom: 4.05rem;
  62. animation: fadeIn ease 2s;
  63. -webkit-animation: fadeIn ease 2s;
  64. border-radius: 0.5rem;
  65. z-index: 3;
  66. }
  67.  
  68. #title {
  69. font: 5rem rosalie;
  70. color: #fff;
  71. text-align: center;
  72. bottom: -3rem;
  73. z-index: 2;
  74. text-shadow: -1px 1px 2px #292436, 1px -1px 2px #292436, 1px 1px 2px #292436, -1px -1px 2px #292436;
  75. }
  76.  
  77. #left-wing, #right-wing {
  78. z-index: 1;
  79. bottom: -1.25rem;
  80. height: 3.5rem;
  81. }
  82. #left-wing {
  83. left: 0.5rem;
  84. }
  85. #right-wing {
  86. right: 0.5rem;
  87. }
  88.  
  89. @keyframes
  90. shake {
  91. 0% {
  92. transform: translate(1px, 1px) rotate(0deg);
  93. }
  94. 10% {
  95. transform: translate(-1px, -2px) rotate(-1deg);
  96. }
  97. 20% {
  98. transform: translate(-3px, 0px) rotate(1deg);
  99. }
  100. 30% {
  101. transform: translate(3px, 2px) rotate(0deg);
  102. }
  103. 40% {
  104. transform: translate(1px, -1px) rotate(1deg);
  105. }
  106. 50% {
  107. transform: translate(-1px, 2px) rotate(-1deg);
  108. }
  109. 60% {
  110. transform : translate(-3px, 1px) rotate(0deg);
  111. }
  112. 70% {
  113. transform: translate(3px, 1px) rotate(-1deg);
  114. }
  115. 80% {
  116. transform: translate(-1px, -1px) rotate(1deg);
  117. }
  118. 90% {
  119. transform: translate(1px, 2px) rotate(0deg);
  120. }
  121. 100% {
  122. transform: translate(1px, -2px) rotate(-1deg);
  123. }
  124. }
  125.  
  126. @-webkit-keyframes blur {
  127. 0% {
  128. -webkit-filter: blur(0px);
  129. }
  130. 50% {
  131. -webkit-filter: blur(5px);
  132. }
  133. 100% {
  134. -webkit-filter: blur(0px);
  135. }
  136. }
  137.  
  138. @keyframes
  139. fadeIn {
  140. 0%, 80% {
  141. opacity: 0;
  142. }
  143. 100% {
  144. opacity: 1;
  145. }
  146. }
  147. @-webkit-keyframes fadeIn {
  148. 0%, 80% {
  149. opacity: 0;
  150. }
  151. 100% {
  152. opacity: 1;
  153. }
  154. }
  155. </style>
  156.  
  157. <div id="container" onclick="showBox()">
  158. <img id="left-wing" src="https://dl.dropbox.com/s/kt5585xmp8b1smg/097ABBB3-8542-47DE-BDA3-9B3037C50CA4.gif">
  159. <img id="right-wing" src="https://dl.dropbox.com/s/b9i2lb6eyxx3qj2/5DEC2971-2293-443B-BE85-E6178C40E553.gif">
  160. <span id="title">Name</span>
  161. <img id="figure" src="https://64.media.tumblr.com/4c9be05c255aa8181575ffff18bd15af/52dbaf2298cde065-f1/s1280x1920/d9eed2c101b63d893122bdd5c3a2fd5a89fc090b.jpg">
  162. <div id="box">
  163. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer facilisis diam sit amet vestibulum blandit. Nunc in ex a quam scelerisque vestibulum id id risus. Praesent auctor justo ut odio laoreet, eu suscipit libero pellentesque. Integer id dapibus est, id tempor magna. Curabitur in dui eget mauris hendrerit aliquam. Proin id ex nec odio commodo suscipit vel vel velit. Nam congue aliquam velit vel placerat.
  164. </div>
  165. </div>
  166.  
  167. <script>
  168. function showBox() {
  169. var box = document.getElementById("box");
  170. box.style.display = "block";
  171. }
  172.  
  173. document.addEventListener("click", function(event) {
  174. var container = document.getElementById("container");
  175. var box = document.getElementById("box");
  176. if (event.target != container && !container.contains(event.target)) {
  177. box.style.display = "none";
  178. }
  179. });
  180. </script>
  181. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement