In this post, we will learn how to create a hover effect using Html and CSS. In the last post, we discussed how to create a Click to Show Context menu. But now our focus is to develop hover effects using Html and CSS.
Hover effect in CSS:
As you can see in the demo we have created different hover effects and we have created these hover effects using Html and CSS. We have built three different texts and all of them have different hover effects.
It is possible because we have used CSS in it. CSS is specifically used to design web pages. It is also a part of the website.
The code of these hover effects is present in this post and you can download and copy its code.
How to create a Hover effect in CSS?
Download a code editor for the hover effect:
Code Editor is used to writing the code of programming language and you can use any code editor which supports Html CSS, and javascript. VS Code, sublime text editor 3 or brackets.
Source code of HTML:
It is a markup language and we have used it to write the words of the hover effects and we have created div using CSS The code of the Hover effect is present below and you can use it in your file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <link rel="stylesheet" href="style.css"> <title>Link Hover effect using Html and CSS | FantacyDesigns</title> </head> <body> <div class="background-one"> <div class="link-container"> <a class="link-one" href="https://jhancock532.github.io/link-hover-effects/">Three</a> </div> </div> <div class="background-two link-container"> <a class="link-two" href="https://jhancock532.github.io/link-hover-effects/">Fancy</a> </div> <div class="background-three link-container"> <a class="link-three" href="https://jhancock532.github.io/link-hover-effects/">Links</a> </div> </body> </html> |
Source code of CSS:
It is also a markup language and we have used it to create the design of this project. Most important thing is that we have created a hover effect in CSS and we can design any part of the website using CSS.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
body { margin: 0; height: 100vh; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: 1fr; } .background-one { background-color: #151515;font-family:arial; } .background-two { background-color: #151515; } .background-three { background-color: #151515; } .link-container { display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%; position: relative; z-index: 0; } a { font-family: "Bungee", cursive; font-size: 2.5em; } .link-one { color: #53d9d1; transition: color 1s cubic-bezier(0.32, 0, 0.67, 0); line-height: 1em; } .link-one:hover { color: #111; transition: color 1s cubic-bezier(0.33, 1, 0.68, 1); /* Thanks Chris Coyier, you got my back always. https://css-tricks.com/different-transitions-for-hover-on-hover-off/ */ } .link-one::before { content: ""; position: absolute; z-index: -1; width: 100%; height: 100%; top: 0; right: 0; background-color: #53d9d1; clip-path: circle(0% at 50% calc(50%)); transition: clip-path 1s cubic-bezier(0.65, 0, 0.35, 1); } .link-one:hover::before { clip-path: circle(100% at 50% 50%); } .link-one::after { content: ""; position: absolute; z-index: -1; width: 100%; height: 100%; top: 0; right: 0; background-color: #151515; clip-path: polygon( 40% 0%, 60% 0%, 60% 0%, 40% 0%, 40% 100%, 60% 100%, 60% 100%, 40% 100% ); /* Didn't look consistently awesome enough across different viewing widths. clip-path: polygon( 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50%, 50% 50% ); */ transition: clip-path 1s cubic-bezier(0.65, 0, 0.35, 1); } .link-one:hover::after { /* clip-path: polygon( 20% 45%, 10% 40%, 30% 30%, 40% 35%, 60% 35%, 70% 30%, 90% 40%, 80% 45%, 60% 35%, 40% 35%, 20% 45%, 20% 55%, 10% 60%, 30% 70%, 40% 65%, 60% 65%, 70% 70%, 90% 60%, 80% 55%, 60% 65%, 40% 65%, 20% 55% ); */ clip-path: polygon( 40% 10%, 60% 10%, 60% 35%, 40% 35%, 40% 90%, 60% 90%, 60% 65%, 40% 65% ); } .link-two { color: #f27b9b; transition: color 1s cubic-bezier(0.32, 0, 0.67, 0); } .link-two:hover { color: #111; transition: color 1s cubic-bezier(0.33, 1, 0.68, 1); } .link-two::before { content: ""; position: absolute; z-index: -2; width: 100%; height: 100%; top: 0; right: 0; clip-path: polygon( 0% -20%, 100% -30%, 100% -10%, 0% 0%, 0% 130%, 100% 120%, 100% 100%, 0% 110% ); background-color: #f27b9b; transition: clip-path 1s cubic-bezier(0.25, 1, 0.5, 1); } .link-two:hover::before { clip-path: polygon( 0% 10%, 100% 0%, 100% 20%, 0% 30%, 0% 100%, 100% 90%, 100% 70%, 0% 80% ); } .link-two::after { content: ""; position: absolute; z-index: -1; width: 5ch; height: 5ch; top: 50%; right: 50%; transform: translate(50%, -50%) rotate(0deg) scale(0); transition: transform 1s ease; background-color: #f27b9b; } .link-two:hover::after { transform: translate(50%, -50%) rotate(135deg) scale(1); } .link-three { color: #eb7132; } .link-three::after { content: ""; position: absolute; z-index: 2; width: 50%; height: 100%; top: 0%; left: 0%; transform: translate(0, -50%) scaleY(0); transition: transform 1s ease; mix-blend-mode: difference; clip-path: polygon( 20% 60%, 100% 60%, 100% 40%, 20% 40%, 20% 0%, 60% 0%, 60% 20%, 20% 20% ); background-color: #eb7132; } .link-three:hover::after { transform: translate(0, 0%) scaleY(1); } .link-three::before { content: ""; position: absolute; z-index: 2; width: 50%; height: 100%; bottom: 0%; right: 0%; transform: translate(0, 50%) scaleY(0); transition: transform 1s ease; mix-blend-mode: difference; clip-path: polygon( 80% 40%, 0% 40%, 0% 60%, 80% 60%, 80% 100%, 40% 100%, 40% 80%, 80% 80% ); background-color: #eb7132; } .link-three:hover::before { transform: translate(0%, 0%) scaleY(1); } |
Download source code:
We have created a file and in this file all the code files are present. You just need to click on the link of download and you will be able to download and access the files.
If you find it helpful then must like and share it. It will help us to create more content like this.
Thanks for reading it.
Download Source CodeClick to Download