Direction-aware hover with pure css
How do I make an direction-aware hover with pure css?
Just a little experiment to see if I could reproduce this hover effect with just css: http://tympanus.net/codrops/2012/04/09/direction-aware-hover-effect-with-css3-and-jquery/. What is a direction-aware hover with pure css? How do you make a direction-aware hover with pure css? This script and codes were developed by Zachary Olson on 10 November 2022, Thursday.
Direction-aware hover with pure css - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Direction-aware hover with pure css</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="hoverable"> <div class="hoverable-exit"></div> <div class="hoverable-exit"></div> <div class="hoverable-exit"></div> <div class="hoverable-exit"></div> <div class="hoverable-content-wrap"> <div class="hoverable-enter"></div> <div class="hoverable-enter"></div> <div class="hoverable-enter"></div> <div class="hoverable-enter"></div> <div class="hoverable-content"> Hovering Content. </div> </div>
</div>
<div class="hoverable"> <div class="hoverable-exit"></div> <div class="hoverable-exit"></div> <div class="hoverable-exit"></div> <div class="hoverable-exit"></div> <div class="hoverable-content-wrap"> <div class="hoverable-enter"></div> <div class="hoverable-enter"></div> <div class="hoverable-enter"></div> <div class="hoverable-enter"></div> <div class="hoverable-content"> Hovering Content. </div> </div>
</div>
<div class="hoverable"> <div class="hoverable-exit"></div> <div class="hoverable-exit"></div> <div class="hoverable-exit"></div> <div class="hoverable-exit"></div> <div class="hoverable-content-wrap"> <div class="hoverable-enter"></div> <div class="hoverable-enter"></div> <div class="hoverable-enter"></div> <div class="hoverable-enter"></div> <div class="hoverable-content"> Hovering Content. </div> </div>
</div>
</body>
</html>
Direction-aware hover with pure css - Script Codes CSS Codes
/* Logic */
.hoverable { position: relative; width: 200px; height: 200px;
}
.hoverable-content { opacity: 0; -webkit-animation-fill-mode: forwards; -webkit-animation-duration: 0.1s;
}
.hoverable:hover .hoverable-content { opacity: 1;
}
.hoverable-content-wrap, .hoverable-content, .hoverable-exit { position: absolute; width: 100%; height: 100%;
}
.hoverable-content-wrap { overflow: hidden;
}
/* Exit areas are full size and shifted to one side of square. */
.hoverable-exit { display: none; z-index: 2;
}
.hoverable:hover .hoverable-exit { display: block;
}
.hoverable-exit:nth-of-type(1), .hoverable-exit:nth-of-type(2) { width: 50px;
}
.hoverable-exit:nth-of-type(4), .hoverable-exit:nth-of-type(3) { height: 50px;
}
.hoverable-exit:nth-of-type(1) { left: 100%;
}
.hoverable-exit:nth-of-type(2) { right: 100%;
}
.hoverable-exit:nth-of-type(3) { bottom: 100%;
}
.hoverable-exit:nth-of-type(4) { top: 100%;
}
/* Enter areas are triangles inside box - actually built with rotated squares that are shifted halfway towards various sides */
.hoverable-enter { position: absolute; top: 0; left: 0; right: 0; bottom: 0; margin: auto; width: 141.42136px; height: 141.42136px; z-index: 1;
}
.hoverable-enter:nth-of-type(1) { -webkit-transform: translate(70%, 0%) rotate(45deg);
}
.hoverable-enter:nth-of-type(2) { -webkit-transform: translate(-70%, 0) rotate(45deg);
}
.hoverable-enter:nth-of-type(3) { -webkit-transform: translate(0, -70%) rotate(45deg);
}
.hoverable-enter:nth-of-type(4) { -webkit-transform: translate(0, 70%) rotate(45deg);
}
/* Enter area in use should cover whole area so other enter areas dont get triggered. */
.hoverable-enter:hover { display: block; -webkit-transform: none; z-index: 2; width: 100%; height: 100%;
}
.hoverable-enter:nth-of-type(1):hover ~ .hoverable-content { -webkit-animation-name: enter-left;
}
.hoverable:hover .hoverable-enter:nth-of-type(2):hover ~ .hoverable-content { -webkit-animation-name: enter-right;
}
.hoverable:hover .hoverable-enter:nth-of-type(3):hover ~ .hoverable-content { -webkit-animation-name: enter-bottom;
}
.hoverable:hover .hoverable-enter:nth-of-type(4):hover ~ .hoverable-content { -webkit-animation-name: enter-top;
}
.hoverable-exit:nth-of-type(1):hover ~ .hoverable-content-wrap .hoverable-content { -webkit-animation-name: exit-right;
}
.hoverable-exit:nth-of-type(2):hover ~ .hoverable-content-wrap .hoverable-content { -webkit-animation-name: exit-left;
}
.hoverable-exit:nth-of-type(3):hover ~ .hoverable-content-wrap .hoverable-content { -webkit-animation-name: exit-top;
}
.hoverable-exit:nth-of-type(4):hover ~ .hoverable-content-wrap .hoverable-content { -webkit-animation-name: exit-bottom;
}
/* Animations */
@-webkit-keyframes enter-top { from { bottom: -100%; } to { bottom: 0; }
}
@-webkit-keyframes enter-left { from { left: 100%; } to { left: 0; }
}
@-webkit-keyframes enter-bottom { from { bottom: 100%; } to { bottom: 0; }
}
@-webkit-keyframes enter-right { from { left: -100%; } to { left: 0; }
}
@-webkit-keyframes exit-top { from { top: 0; } to { top: -100%; }
}
@-webkit-keyframes exit-left { from { left: 0; } to { left: -100%; }
}
@-webkit-keyframes exit-bottom { from { top: 0; } to { top: 100%; }
}
@-webkit-keyframes exit-right { from { left: 0; } to { left: 100%; }
}
/* Styling */
body { width: 900px; margin: auto; background: #EDEBEE;
}
.hoverable { float: left; background: #CCC; margin: 50px 50px;
}
.hoverable-content { padding: 1em; box-sizing: border-box; background-color: #806973; color: #FFF; text-align: center; font-family: helvetica, sans-serif;
}
/*
.hoverable-exit { background: blue;
}*/
Developer | Zachary Olson |
Username | zacharyolson |
Uploaded | November 10, 2022 |
Rating | 3 |
Size | 3,596 Kb |
Views | 26,312 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Convert JSON to ruby hash | 2,000 Kb |
No JS Modals | 2,843 Kb |
Hovers with popups | 2,380 Kb |
Blackberry Mock | 1,865 Kb |
D3 version of animated chart dribbble | 4,327 Kb |
IPad Mock | 2,008 Kb |
Scroll Position Indicators | 5,711 Kb |
Nerdventure Feed | 4,817 Kb |
IMac Mock | 2,046 Kb |
Border Radius Bouncer | 2,415 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Responsive Menu I | Rodericksandoval | 3,045 Kb |
A Pen by Jay | Jaycode | 3,784 Kb |
Modular Flip Card | Bbodine1 | 4,009 Kb |
P5.js data visualization | Enginarslan | 2,233 Kb |
JS Countdown Timer | Ayoungh | 2,435 Kb |
To Do List with Delete | Mattlbrody | 2,068 Kb |
A Pen by Manoz | Manoz | 2,424 Kb |
Vanilla JS - A toggleClass function | Woodwork | 2,532 Kb |
AngularJS Skills | Supro | 3,312 Kb |
Pure CSS Animated Photo Stack | Depthdev | 2,486 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!