css实现30款不同风格鼠标悬浮导航按钮动画效果代码
代码语言:html
所属分类:悬停
代码描述:css实现30款不同风格鼠标悬浮导航按钮动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>几个简单的导航栏样式</title>
<style>
body {
font-family: 'Raleway', sans-serif;
line-height:normal;
margin:0;
padding:0;
}
html {
font-family:sans-serif;
-ms-text-size-adjust:100%;
-webkit-text-size-adjust:100%;
}
article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary {
display:block;
}
a:focus {
outline:thin dotted;
}
a:active,a:hover {
outline:0;
}
img {
border:0;
}
section {
background:#fff;
margin: 0 auto;
padding: 5em 2em;
text-align: center;
}
section:nth-child(even) {
background: #fafafa;
}
section h2 {
margin: 0;
padding: 0 0 2em;
}
footer {
background: #fafafa;
margin: 0 auto;
padding: 5em 2em;
text-align: center;
}
.container{
margin:0 auto;
}
#header {
background:#a89ef1;
font-family: 'Raleway', sans-serif;
padding: 5em 0;
text-align: center;
}
#header i.fa {
color:#6559bc;
font-size:35px;
}
#header h1 {
color: #6559bc;
font-size: 2.5em;
font-weight: 300;
margin: 0;
padding: 0.3em 0;
}
#header h3 small {
color:#6559bc;
font-weight:normal;
background: #fff none repeat scroll 0 0;
font-size: 13px;
padding: 0 12px;
}
#header h3 {
border-bottom: 1px solid #6559bc;
color: #fff;
margin: 0 auto 12px;
padding: 0 0 5px;
width: 35%;
}
#header p {
color: #fff;
display: inline-block;
margin: 0;
padding: 0;
}
.rtnav{
background:#6559bc;
width: 100%;
border-bottom: 1px solid #e1e1e1;
/* animation magic */
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
z-index: 9999;
top: 0;
position: fixed;
}
.shrink {
padding: 20px 0;
}
.rtnav ul{
text-align:center;
margin:0;
padding:0;
}
.rtnav ul li{
list-style:none;
display:inline-block;
}
.rtnav a {
color: #fff;
display: inline-block;
font-size: 14px;
font-weight: 300;
letter-spacing: 1px;
padding:20px 10px;
outline: medium none;
position: relative;
text-decoration: none;
text-transform: capitalize;
}
.rtnav a:hover,
.rtnav a:focus {
outline: none;
}
/* ******************************************************
Basic Styling
*********************************************************/
.ayanEffects ul{
margin:0;
padding:0;
text-align:center;
}
.ayanEffects li{
list-style:none;
display:inline-block;
margin: 15px 25px;
}
.ayanEffects li a{
font-family: 'Lato', sans-serif;
font-weight: 400;
font-size: 1.35em;
position: relative;
display: inline-block;
outline: none;
color: #000;
text-decoration: none;
text-transform: uppercase;
letter-spacing: 1px;
}
.ayanEffects a:hover,
.ayanEffects a:focus {
outline: none;
}
/* ******************************************************
Effect 1: Swipe .ayanHoverEffect_1
*********************************************************/
.ayanHoverEffect_1 li a {
position: relative;
overflow: hidden;
display: block;
text-align: center;
-webkit-box-flex: 1;
-webkit-flex-grow: 1;
-ms-flex-positive: 1;
flex-grow: 1;
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
.ayanHoverEffect_1 li a span {
display: block;
-webkit-transition: -webkit-transform 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
transition: -webkit-transform 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
transition: transform 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
transition: transform 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55), -webkit-transform 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.ayanHoverEffect_1 li a:after {
position: absolute;
top: 100%;
left: 0;
right: 0;
content: attr(data-link-alt);
display: inline;
text-align: center;
-webkit-transition: top 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
transition: top 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.ayanHoverEffect_1 li a:hover {
color:#6559bc;
cursor: -webkit-grab;
cursor: grab;
}
.ayanHoverEffect_1 li a:hover span {
color:#6559bc;
-webkit-transform: translateY(-100%);
transform: translateY(-100%);
}
.ayanHoverEffect_1 li a:hover:after {
top: 0;
}
.ayanHoverEffect_1 li a:active {
-webkit-animation-name: rubberBand;
animation-name: rubberBand;
cursor: -webkit-grabbing;
cursor: grabbing;
}
/* ******************************************************
Effect 2: Changer .ayanHoverEffect_2
*********************************************************/
.ayanHoverEffect_2 li {
position: relative;
display: inline-block;
overflow: hidden;
}
.ayanHoverEffect_2 li a {
-webkit-transition: -webkit-transform 0.5s ease;
transition: -webkit-transform 0.5s ease;
transition: transform 0.5s ease;
transition: transform 0.5s ease, -webkit-transform 0.5s ease;
-webkit-transition: transform 0.5s ease;
}
.ayanHoverEffect_2 li a:before {
position: absolute;
top: 100%;
content: attr(data-link-alt);
color: #6559bc;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.ayanHoverEffect_2 li:hover a,
.ayanHoverEffect_2 li:focus a {
-webkit-transform: translateY(-100%);
transform: translateY(-100%);
}
/* ******************************************************
Effect 3: Topliner .ayanHoverEffect_3
*********************************************************/
.ayanHoverEffect_3 a {
padding: 0 20px;
line-height: 45px;
}
.ayanHoverEffect_3 a::before {
position: absolute;
content: '';
width: 50px;
height: 3px;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
pointer-events: none;
}
.ayanHoverEffect_3 a:hover{
color:#6559bc;
}
.ayanHoverEffect_3 a:hover::before,
.ayanHoverEffect_3 a:hover::after,
.ayanHoverEffect_3 a:focus::before,
.ayanHoverEffect_3 a:focus::after {
background: #6559bc;
}
.ayanHoverEffect_3 a:hover::before,
.ayanHoverEffect_3 a:focus::before {
left: 50%;
-webkit-transform: rotate(0deg) translateX(-50%);
-moz-transform: rotate(0deg) translateX(-50%);
transform: rotate(0deg) translateX(-50%);
}
.ayanHoverEffect_3 a:hover::after,
.ayanHoverEffect_3 a:focus::after {
right: 50%;
-webkit-transform: rotate(0deg) translateX(50%);
-moz-transform: rotate(0deg) translateX(50%);
transform: rotate(0deg) translateX(50%);
}
/* ******************************************************
Effect 3: Center Line .ayanHoverEffect_4
*********************************************************/
.ayanHoverEffect_4 a {
position: absolute;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.ayanHoverEffect_4 li a {
top: 50%;
left: 50%;
z-index: 1;
text-decoration: none;
outline: 0;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.ayanHoverEffect_4 li a:hover{
color:#6559bc;
}
.ayanHoverEffect_4 li a:after {
background: #6559bc;
content: "";
height: 3px;
width: 0;
position: absolute;
left: 50%;
bottom: -15px;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-transform: translateX(-50%);
-moz-transform: translateX(-50%);
-ms-transform: translateX(-50%);
-o-transform: translateX(-50%);
transform: translateX(-50%);
-webkit-transition: 0.35s all cubic-bezier(0.77, 0, 0.175, 1);
-moz-transition: 0.35s all cubic-bezier(0.77, 0, 0.175, 1);
transition: 0.35s all cubic-bezier(0.77, 0, 0.175, 1);
}
.ayanHoverEffect_4 li a:hover:after {
color:#6559bc;
width: 100%;
}
/* ******************************************************
Effect 5: Roll Box .ayanHoverEffect_5
*********************************************************/
.ayanHoverEffect_5 a {
word-wrap: break-word;
text-decoration: none;
}
.ayanHoverEffect_5 a {
display: inline-block;
perspective: 600px;
perspective-origin: 50% 50%;
overflow: hidden;
}
.ayanHoverEffect_5 a span {
font-family: 'Lato', sans-serif;
font-weight: 400;
position: relative;
outline: none;
color: #000;
text-decoration: none;
text-transform: uppercase;
letter-spacing: 1px;
display: block;
padding: 0 10px;
transform-origin: 50% 0;
transform-style: preserve-3d;
transition: all 400ms ease 0s;
}
.ayanHoverEffect_5 a span:after {
background: none repeat scroll 0 0 #6559bc;
color: #fff;
content: attr(data-link-alt);
display: block;
padding: 0 10px;
position: absolute;
top: 0;
left: 0;
transform: translate3d(0px, 105%, 0px) rotateX(-90deg);
transform-origin: 50% 0%;
}
.ayanHoverEffect_5 a:hover span {
background: none repeat scroll 0 0 #6559bc;
transform: translate3d(0px, 0px, -30px) rotateX(90deg);
}
/* ******************************************************
Effect 6: Starter Line .ayanHoverEffect_6
*********************************************************/
.ayanHoverEffect_6 a::after {
background-color: #6559bc;
content: "";
width: 0;
height: 4px;
position: absolute;
bottom: -10px;
left: 0;
transition: width 500ms ease;
}
.ayanHoverEffect_6 a:hover::after {
width: 100%;
}
/* ******************************************************
Effect 7: Bottom Line .ayanHoverEffect_7
*********************************************************/
.ayanHoverEffect_7 a{
padding:0 0 12px;
}
.ayanHoverEffect_7 a::after {
background-color: #6559bc;
content: "";
height: 4px;
width: 100%;
position: absolute;
bottom: -12px;
left: 0;
opacity: 0;
transition: opacity 300ms ease, bottom 300ms ease;
}
.ayanHoverEffect_7 a:hover::after {
opacity: 1;
bottom: 0;
}
/* ******************************************************
Effect 8: Pop Box .ayanHoverEffect_8
*********************************************************/
.ayanHoverEffect_8 a:link,
.ayanHoverEffect_8 a:visited{
text-decoration:none;
z-index:51;
padding:.5em;
-webkit-transition:all .2s linear .1s;
transition:all .2s linear .1s;
-ms-touch-action:none;
touch-action:none
}
.ayanHoverEffect_8 a:hover,
.ayanHoverEffect_8 a:active,
.ayanHoverEffect_8 a:focus{
color:#fff;
}
.ayanHoverEffect_8 a:after{
background:#6559bc;
position:absolute;
bottom:0;
content:"";
display:block;
z-index:-1;
}
.ayanHoverEffect_8 a:after {
left:50%;
left:-webkit-calc(50% - 2px);
left:calc(50% - 2px);
width:0;
height:1em;
-webkit-transition:all .3s ease;
transition:all .3s ease
}
.ayanHoverEffect_8 a:hover:after,
.ayanHoverEffect_8 a:active:after,
.ayanHoverEffect_8 a:focus:after{
left:0;
width:100%;
height:100%;
background: #6559bc
}
/* ******************************************************
Effect 9: Border Outer .ayanHoverEffect_9
*********************************************************/
.ayanHoverEffect_9 a:link,
.ayanHoverEffect_9 a:visited{
text-decoration:none;
z-index:51;
padding:.5em;
-webkit-transition:all .2s linear .1s;
transition:all .2s linear .1s;
-ms-touch-action:none;
touch-action:none
}
.ayanHoverEffect_9 a:hover,
.ayanHoverEffect_9 a:active,
.ayanHoverEffect_9 a:focus{
color:#6559bc;
}
.ayanHoverEffect_9 a:after{
position:absolute;
bottom:0;
content:"";
display:block;
z-index:-1;
}
.ayanHoverEffect_9 a:after {
left:50%;
left:-webkit-calc(50% - 2px);
left:calc(50% - 2px);
width:0;
height:1em;
-webkit-transition:all .3s ease;
transition:all .3s ease
}
.ayanHoverEffect_9 a:hover:after,
.ayanHoverEffect_9 a:active:after,
.ayanHoverEffect_9 a:focus:after{
border:solid 1px #6559bc;
left:0;
width:100%;
height:100%;
}
/* ******************************************************
Effect 10: Bubbles .ayanHoverEffect_10
*********************************************************/
.ayanHoverEffect_10 a:hover {
color:#6559bc;
-ms-animation: opacity forwards 1s;
-moz-animation: opacity forwards 1s;
-webkit-animation: opacity forwards 1s;
animation: opacity forwards 1s;
}
@keyframes opacity {
0% {
opacity: 1;
}
100% {
opacity: 1;
}
}
.ayanHoverEffect_10 a:before,
.ayanHoverEffect_10 a:after {
position: absolute;
top: 0px;
left: 0;
content: "鈼�";
display: block;
width: 100%;
font-size: 0px;
color: #6559bc;
text-align: center;
z-index: -100;
}
.ayanHoverEffect_10 a:hover::before {
animation: drop 1s;
-ms-animation: drop 1s;
-moz-animation: drop 1s;
-webkit-animation: drop 1s;
}
.ayanHoverEffect_10 a:hover::after {
animation: drop 1s 0.5s;
-ms-animation: drop 1s 0.5s;
-moz-animation: drop 1s 0.5s;
-webkit-animation: drop 1s 0.5s;
}
@keyframes drop {
0% {
opacity: 1;
font-size: 0;
top: 0;
}
100% {
opacity: 0;
font-size: 80px;
top: -50px;
}
}
/* ******************************************************
Effect 11: Classic .ayanHoverEffect_11
*********************************************************/
.ayanHoverEffect_11 a {
margin:0;
padding: 15px 25px;
position: relative;
overflow: hidden;
display: inline-block;
-moz-transition: ease-out 0.3s;
-o-transition: ease-out 0.3s;
-webkit-transition: ease-out 0.3s;
transition: ease-out 0.3s;
}
.ayanHoverEffect_11 a span::before {
background: transparent;
width: 6px;
height: 6px;
content: "";
position: absolute;
left: 0;
top: 0;
border-top: 2px solid #6559bc;
border-left: 2px solid #6559bc;
-moz-transition: 0.3s;
-o-transition: 0.3s;
-webkit-transition: 0.3s;
transition: 0.3s;
opacity: 0;
}
.ayanHoverEffect_11 a span::after {
background: transparent;
width: 6px;
height: 6px;
content: "";
position: absolute;
right: 0;
bottom: 0;
border-right: 2px solid #6559bc;
border-bottom: 2px solid #6559bc;
-moz-transition: 0.3s;
-o-transition: 0.3s;
-webkit-transition: 0.3s;
transition: 0.3s;
opacity: 0;
}
.ayanHoverEffect_11 a::before {
background: transparent;
width: 6px;
height: 6px;
content: "";
position: absolute;
right: 0;
top: 0;
border-right: 2px solid #6559bc;
border-top: 2px solid #6559bc;
-moz-transition: 0.3s;
-o-transition: 0.3s;
-webkit-transition: 0.3s;
transition: 0.3s;
opacity: 0;
}
.ayanHoverEffect_11 a::after {
background: transparent;
width: 6px;
height: 6px;
content: "";
position: absolute;
left: 0;
bottom: 0;
border-left: 2px solid #6559bc;
border-bottom: 2px solid #6559bc;
-moz-transition: 0.3s;
-o-transition: 0.3s;
-webkit-transition: 0.3s;
transition: 0.3s;
opacity: 0;
}
.ayanHoverEffect_11 a:hover {
color: #6559bc;
}
.ayanHoverEffect_11 a:hover::before {
opacity: 1;
right: 6px;
top: 6px;
}
.ayanHoverEffect_11 a:hover::after {
opacity: 1;
left: 6px;
bottom: 6px;
}
.ayanHoverEffect_11 a:hover span::before {
opacity: 1;
left: 6px;
top: 6px;
}
.ayanHoverEffect_11 a:hover span::after {
opacity: 1;
right: 6px;
bottom: 6px;
}
/* ******************************************************
Effect 12: Border Style #1 .ayanHoverEffect_12
*********************************************************/
.ayanHoverEffect_12 a {
padding: 10px 14px;
position: relative;
-moz-transition: ease-out 0.3s 0.1s;
-o-transition: ease-out 0.3s 0.1s;
-webkit-transition: ease-out 0.3s;
-webkit-transition-delay: 0.1s;
transition: ease-out 0.3s 0.1s;
}
.ayanHoverEffect_12 a span::before {
height: 100%;
width: 2px;
background: #6559bc;
content: "";
position: absolute;
left: 0;
top: 0;
-moz-transform: scaleY(0);
-ms-transform: scaleY(0);
-webkit-transform: scaleY(0);
transform: scaleY(0);
-moz-transition: 0.3s;
-o-transition: 0.3s;
-webkit-transition: 0.3s;
transition: 0.3s;
}
.ayanHoverEffect_12 a span::after {
height: 100%;
width: 2px;
background: #6559bc;
content: "";
position: absolute;
right: 0;
top: 0;
-moz-transform: scaleY(0);
-ms-transform: scaleY(0);
-webkit-transform: scaleY(0);
transform: scaleY(0);
-moz-transition: 0.3s;
-o-transition: 0.3s;
-webkit-transition: 0.3s;
transition: 0.3s;
}
.ayanHoverEffect_12 a::before {
height: 2px;
width: 100%;
background: #6559bc;
content: "";
position: absolute;
left: 0;
top: 0;
-moz-transform: scaleX(0);
-ms-transform: scaleX(0);
-webkit-transform: scaleX(0);
transform: scaleX(0);
-moz-transition: 0.3s;
-o-transition: 0.3s;
-webkit-transition: 0.3s;
transition: 0.3s;
}
.ayanHoverEffect_12 a::after {
height: 2px;
width: 100%;
background: #6559bc;
content: "";
position: absolute;
left: 0px;
bottom: 0;
-moz-transform: scaleX(0);
-ms-transform: scaleX(0);
-webkit-transform: scaleX(0);
transform: scaleX(0);
-moz-transition: 0.3s;
-o-transition: 0.3s;
-webkit-transition: 0.3s;
transition: 0.3s;
}
.ayanHoverEffect_12 a:hover {
color: #6559bc;
}
.ayanHoverEffect_12 a:hover::before, .ayanHoverEffect_12 a:hover::after {
-moz-transform: scaleX(1);
-ms-transform: scaleX(1);
-webkit-transform: scaleX(1);
transform: scaleX(1);
}
.ayanHoverEffect_12 a:hover span::before, .ayanHoverEffect_12 a:hover span::after {
-moz-transform: scaleY(1);
-ms-transform: scaleY(1);
-webkit-transform: scaleY(1);
transform: scaleY(1);
}
/* ******************************************************
Effect 13: Border Style #2 .ayanHoverEffect_13
*********************************************************/
.ayanHoverEffect_13 a {
color: #797878;
margin: 0 20px;
padding: 10px;
position: relative;
overflow: hidden;
display: inline-block;
-moz-transition: ease-out 0.3s 0.1s;
-o-transition: ease-out 0.3s 0.1s;
-webkit-transition: ease-out 0.3s;
-webkit-transition-delay: 0.1s;
transition: ease-out 0.3s 0.1s;
}
.ayanHoverEffect_13 a span::before {
width: 100%;
height: 2px;
background: #6559bc;
content: "";
position: absolute;
left: 0;
top: 0;
-moz-transition: 0.3s;
-o-transition: 0.3s;
-webkit-transition: 0.3s;
transition: 0.3s;
-moz-transform: translateX(-100%);
-ms-transform: translateX(-100%);
-webkit-transform: translateX(-100%);
transform: translateX(-100%);
}
.ayanHoverEffect_13 a span::after {
width: 100%;
height: 2px;
background: #6559bc;
content: "";
position: absolute;
right: 0;
bottom: 0;
-moz-transition: 0.3s;
-o-transition: 0.3s;
-webkit-transition: 0.3s;
transition: 0.3s;
-moz-transform: translateX(100%);
-ms-transform: translateX(100%);
-webkit-transform: translateX(100%);
transform: translateX(100%);
}
.ayanHoverEffect_13 a::before {
width: 2px;
height: 100%;
background: #6559bc;
content: "";
position: absolute;
left: 0;
top: 0;
-moz-transform: translateY(-100%);
-ms-transform: translateY(-100%);
-webkit-transform: translateY(-100%);
tra.........完整代码请登录后点击上方下载按钮下载查看
网友评论0