Skip to content

Instantly share code, notes, and snippets.

@joellesenne
Last active September 4, 2020 05:24
Show Gist options
  • Save joellesenne/9750296 to your computer and use it in GitHub Desktop.
Save joellesenne/9750296 to your computer and use it in GitHub Desktop.
A Pen by Lesenne.
<div class="container">
<nav class="menu animated flipInX">
<h2>Animate menu CSS</h2>
<ul>
<a href="#">
<h3>Link 1</h3>
<p>text 1</p>
</a>
<a href="#">
<h3>Link 2</h3>
<p>text 2</p>
</a>
<a href="#">
<h3>Link 3</h3>
<p>text 3</p>
</a>
<a href="#">
<h3>Link 4</h3>
<p>text 4</p>
</a>
<a href="#">
<h3>Link 5</h3>
<p>text 5</p>
</a>
<a href="http://macreart.com">
<p>&copy; 2011/2014 | macreart.com | F . Lesenne</p>
</a>
</ul>
</nav>
</div>
// Animate menu mouseover, pure CSS
// inspired: <https://bennettfeely.com>
// Author Joël Lesenne <https://joellesenne.dev>
@import url(http://fonts.googleapis.com/css?family=Lato:400,700);
*,
*:before,
*:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
* {
font-weight: 400;
margin: 0;
padding: 0;
vertical-align: 0;
border:0;
}
aside,figcaption,figure,footer,header,nav,section {
display: block;
}
body {
text-align: center;
font-family: 'Lato', sans-serif;
font-size: 15px;
background: #d8ecf2;
color: RGBA(67, 83, 99, 1);
}
.container {
width: 350px;
max-width: 350px;
margin: 0 auto;
}
h2 {
position: relative;
font-size: 2.8rem;
text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.4);
padding: 1.8rem 0;
}
a {
text-decoration: none;
color: RGBA(67, 83, 99, 1);
cursor: -webkit-zoom-in;
cursor: zoom-in;
}
nav {
-webkit-box-flex: auto;
-webkit-flex: auto;
-ms-flex: auto;
flex: auto;
position: relative;
padding: .6125rem .6152rem 1.6125rem;
}
ul {
text-align: left;
-webkit-transition: all 400ms ease-in-out;
-moz-transition: all 400ms ease-in-out;
-ms-transition: all 400ms ease-in-out;
-o-transition: all 400ms ease-in-out;
transition: all 400ms ease-in-out;
}
ul:hover {
-webkit-transform: scale(0.97);
transform: scale(0.97);
}
ul a {
display: block;
position: relative;
padding: .75rem 1rem 1rem;
-webkit-transition: -webkit-transform .22s,box-shadow .22s;
transition: transform .22s,box-shadow .22s;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
user-drag: none;
box-shadow: 0 0 0 -.25rem rgba(0,0,0,.1);
}
ul a:focus, ul a:hover {
outline: 0;
box-shadow: 0 .5rem 0 -.25rem rgba(0,0,0,.1)
}
ul a:focus, ul a:hover {
-webkit-transform: scale(1.03);
transform:scale(1.03);
-webkit-transition: -webkit-transform .088s,box-shadow .088s;
transition: transform .088s,box-shadow .088s;
z-index: 1;
}
.menu a:nth-child(1) {
background: #95c5db;
}
.menu a:nth-child(2) {
background: #94c1db;
}
.menu a:nth-child(3) {
background: #94bddb;
}
.menu a:nth-child(4) {
background: #94b9db;
}
.menu a:nth-child(5) {
background: #94b5db;
}
.menu a:nth-child(6) {
background: #94b2db;
}
.animated {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
@-webkit-keyframes flipInX {
0% {
-webkit-transform: perspective(400px) rotateX(90deg);
transform: perspective(400px) rotateX(90deg);
opacity: 0;
}
40% {
-webkit-transform: perspective(400px) rotateX(-10deg);
transform: perspective(400px) rotateX(-10deg);
}
70% {
-webkit-transform: perspective(400px) rotateX(10deg);
transform: perspective(400px) rotateX(10deg);
}
100% {
-webkit-transform: perspective(400px) rotateX(0deg);
transform: perspective(400px) rotateX(0deg);
opacity: 1;
}
}
@keyframes flipInX {
0% {
-webkit-transform: perspective(400px) rotateX(90deg);
-ms-transform: perspective(400px) rotateX(90deg);
transform: perspective(400px) rotateX(90deg);
opacity: 0;
}
40% {
-webkit-transform: perspective(400px) rotateX(-10deg);
-ms-transform: perspective(400px) rotateX(-10deg);
transform: perspective(400px) rotateX(-10deg);
}
70% {
-webkit-transform: perspective(400px) rotateX(10deg);
-ms-transform: perspective(400px) rotateX(10deg);
transform: perspective(400px) rotateX(10deg);
}
100% {
-webkit-transform: perspective(400px) rotateX(0deg);
-ms-transform: perspective(400px) rotateX(0deg);
transform: perspective(400px) rotateX(0deg);
opacity: 1;
}
}
.flipInX {
-webkit-backface-visibility: visible !important;
-ms-backface-visibility: visible !important;
backface-visibility: visible !important;
-webkit-animation-name: flipInX;
animation-name: flipInX;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment