16种css悬停按钮动画效果代码

代码语言:html

所属分类:悬停

代码描述:16种css悬停按钮动画效果代码

代码标签: 按钮 动画 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">

  
  
  
  
<style>
body {
  background: #292929;
  padding-left: 30px;
}

.row {
  float: left;
  width: 100%;
}

.row .block {
  float: left;
  width: 25%;
  height: 150px;
}

.hovicon {
  display: inline-block;
  font-size: 45px;
  line-height: 90px;
  cursor: pointer;
  margin: 20px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  text-align: center;
  position: relative;
  text-decoration: none;
  z-index: 1;
  color: #fff;
}

.hovicon.small {
  font-size: 20px;
  line-height: 45px;
  width: 45px;
  height: 45px;
  margin: 7px;
}

.hovicon.mini {
  font-size: 15px;
  line-height: 32px;
  width: 30px;
  height: 30px;
  margin: 7px;
}

.hovicon.auto-width {
  width: auto;
  height: auto;
  padding: 15px;
}

.hovicon:after {
  pointer-events: none;
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  content: '';
  -webkit-box-sizing: content-box;
  -moz-box-sizing: content-box;
  box-sizing: content-box;
}

.hovicon:before {
  speak: none;
  font-size: 48px;
  line-height: 90px;
  font-style: normal;
  font-weight: normal;
  font-variant: normal;
  text-transform: none;
  display: block;
  -webkit-font-smoothing: antialiased;
}

/* Effect 1 */
.hovicon.effect-1 {
  background: rgba(255, 255, 255, 0.1);
  -webkit-transition: background 0.2s, color 0.2s;
  -moz-transition: background 0.2s, color 0.2s;
  transition: background 0.2s, color 0.2s;
}

.hovicon.effect-1:after {
  top: -7px;
  left: -7px;
  padding: 7px;
  box-shadow: 0 0 0 4px #fff;
  -webkit-transition: -webkit-transform 0.2s, opacity 0.2s;
  -webkit-transform: scale(0.8);
  -moz-transition: -moz-transform 0.2s, opacity 0.2s;
  -moz-transform: scale(0.8);
  -ms-transform: scale(0.8);
  transition: transform 0.2s, opacity 0.2s;
  transform: scale(0.8);
  opacity: 0;
}

/* Effect 1a */
.hovicon.effect-1.sub-a:hover {
  background: white;
  color: #41ab6b;
}

.hovicon.effect-1.sub-a:hover i {
  color: #41ab6b;
}

.hovicon.effect-1.sub-a:hover:after {
  -webkit-transform: scale(1);
  -moz-transform: scale(1);
  -ms-transform: scale(1);
  transform: scale(1);
  opacity: 1;
}

/* Effect 1b */
.hovicon.effect-1.sub-b:hover {
  background: white;
  color: #41ab6b;
}

.hovicon.effect-1.sub-b:hover i {
  color: #41ab6b;
}

.hovicon.effect-1.sub-b:after {
  -webkit-transform: scale(1.2);
  -moz-transform: scale(1.2);
  -ms-transform: scale(1.2);
  transform: scale(1.2);
}

.hovicon.effect-1.sub-b:hover:after {
  -webkit-transform: scale(1);
  -moz-transform: scale(1);
  -ms-transform: scale(1);
  transform: scale(1);
  opacity: 1;
}

/* Effect 2 */
.hovicon.effect-2 {
  color: #eea303;
  box-shadow: 0 0 0 3px #fff;
  -webkit-transition: color 0.3s;
  -moz-transition: color 0.3s;
  transition: color 0.3s;
}

.hovicon.effect-2:after {
  top: -2px;
  left: -2px;
  padding: 2px;
  z-index: -1;
  background: #fff;
  -webkit-transition: -webkit-transform 0.2s, opacity 0.2s;
  -moz-transition: -moz-transform 0.2s, opacity 0.2s;
  transition: transform 0.2s, opacity 0.2s;
}

/* Effect 2a */
.hovicon.effect-2.sub-a:hover, .hovicon.effect-2.sub-a:hover i {
  color: #eea303;
}

.hovicon.effect-2.sub-a:hover:after {
  -webkit-transform: scale(0.85);
  -moz-transform: scale(0.85);
  -ms-transform: scale(0.85);
  transform: scale(0.85);
}

/* Effect 2b */
.hovicon.effect-2.sub-b:hover:after {
  -webkit-transform: scale(0);
  -moz-transform: scale(0);
  -ms-transform: scale(0);
  transform: scale(0);
  opacity: 0;
  -webkit-transition: -webkit-transform 0.4s, opacity 0.2s;
  -moz-transition: -moz-transform 0.4s, opacity 0.2s;
  transition: transform 0.4s, opacity 0.2s;
}

.hovicon.effect-2.sub-b:hover, .hovicon.effect-2.sub-b:hover i {
  color: #fff;
}

/* Effect 3 */
.hovicon.effect-3 {
  box-shadow: 0 0 0 4px #fff;
  -webkit-transition: color 0.3s;
  -moz-transition: color 0.3s;
  transition: color 0.3s;
}

.hovicon.effect-3:after {
  top: -2px;
  left: -2px;
  padding: 2px;
  z-index: -1;
  background: #fff;
  -webkit-transition: -webkit-transform 0.2s, opacity 0.3s;
  -moz-transition: -moz-transform 0.2s, opacity 0.3s;
  transition: transform 0.2s, opacity 0.3s;
}

/* Effect 3a */
.hovicon.effect-3.sub-a, .hovicon.effect-3.sub-a i {
  color: #f06060;
}

.hovicon.effect-3.sub-a:hover, .hovicon.effect-3.sub-a:hover i {
  color: #fff;
}

.hovicon.effect-3.sub-a:hover:after {
  -webkit-transform: scale(1.3);
  -moz-transform: scale(1.3);
  -ms-transform: scale(1.3);
  transform: scale(1.3);
  opacity: 0;
}

/* Effect 3b */
.hovicon.effect-3.sub-b, .hovicon.effect-3.sub-b i {
  color: #fff;
}

.hovicon.effect-3.sub-b:hover, .hovicon.effect-3.sub-b:hover i {
  color: #f06060;
}

.hovicon.effect-3.sub-b:after {
  -webkit-transform: scale(1.3);
  -moz-transform: scale(1.3);
  -ms-transform: scale(1.3);
  transform: scale(1.3);
  opacity: 0;
}

.hovicon.effect-3.sub-b:hover:after {
  -webkit-transform: scale(1);
  -moz-transform: scale(1);
  -ms-transform: scale(1);
  transform: scale(1);
  opacity: 1;
}

/* Effect 4 */
.hovicon.effect-4 {
  width: 92px;
  height: 92px;
  box-shadow: 0 0 0 4px white;
}

.hovicon.effect-4.small {
  width: 45px;
  height: 45px;
}

.hovicon.effect-4.mini {
  width: 30px;
  height: 30px;
}

.hovicon.effect-4.sub-a {
  -webkit-transition: box-shadow 0.2s;
  -moz-transition: box-shadow 0.2s;
  transition: box-shadow 0.2s;
}

.hovicon.effect-4:before {
  line-height: 92px;
}

.hovicon.effect-4:after {
  top: -4px;
  left: -4px;
  padding: 0;
  z-index: 10;
  border: 4px dashed #fff;
}

.hovicon.effect-4:hover {
  box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  color: #fff;
}

.hovicon.effect-4:hover i {
  color: #fff;
}

/* Effect 4b */
.hovicon.effect-4.sub-b:hover {
  -webkit-transition: box-shadow 0.2s;
  -moz-transition: box-shadow 0.2s;
  transition: box-shadow 0.2s;
}

.hovicon.effect-4.sub-b:hover:after {
  -webkit-animation: spinAround 9s linear infinite;
  -moz-animation: spinAround 9s linear infinite;
  animation: spinAround 9s linear infinite;
}

@-webkit-keyframes spinAround {
  from {
    -webkit-transform: rotate(0deg);
  }
  to {
    -webkit-transform: rotate(360deg);
  }
}
@-moz-keyframes spinAround {
  from {
    -moz-transform: rotate(0deg);
  }
  to {
    -moz-transform: rotate(360deg);
  }
}
@keyframes spinAround {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
/* Effect 5 */
.hovicon.effect-5 {
  box-shadow: 0 0 0 4px white;
  overflow: hidden;
  -webkit-transition: background 0.3s, color 0.3s, box-shadow 0.3s;
  -moz-transition: background 0.3s, color 0.3s, box-shadow 0.3s;
  transition: background 0.3s, color 0.3s, box-shadow 0.3s;
}

.hovicon.effect-5:after {
  display: none;
}

.hovicon.effect-5:hover {
  background: white;
  color: #702fa8;
  box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.3);
}

.hovicon.effect-5:hover i {
  color: #702fa8;
}

.hovicon.effect-5.sub-a:hover:before {
  -webkit-animation: toRightFromLeft 0.3s forwards;
  -moz-animation: toRightFromLeft 0.3s forwards;
  animation: toRightFromLeft 0.3s forwards;
}

@-webkit-keyframes toRightFromLeft {
  49% {
    -webkit-transform: translate(100%);
  }
  50% {
    opacity: 0;
    -webkit-transform: translate(-100%);
  }
  51% {
    opacity: 1;
  }
}
@-moz-keyframes toRightFromLeft {
  49% {
    -moz-transform: translate(100%);
  }
  50% {
    opacity: 0;
    -moz-transform: translate(-100%);
  }
  51% {
    opacity: 1;
  }
}
@keyframes toRightFromLeft {
  49% {
    transform: translate(100%);
  }
  50% {
    opacity: 0;
    transform: translate(-100%);
  }
  51% {
    opacity: 1;
  }
}
.hovicon.effect-5.sub-b:hover:before {
  -webkit-animation: toLeftFromRight 0.3s forwards;
  -moz-animation: toLeftFromRight 0.3s forwards;
  animation: toLeftFromRight 0.3s forwards;
}

@-webkit-keyframes toLeftFromRight {
  49% {
    -webkit-transform: translate(-100%);
  }
  50% {
    opacity: 0;
    -webkit-transform: translate(100%);
  }
  51% {
    opacity: 1;
  }
}
@-moz-keyframes toLeftFromRight {
  49% {
    -moz-transform: translate(-100%);
  }
  50% {
    opacity: 0;
    -moz-transform: translate(100%);
  }
  51% {
    opacity: 1;
  }
}
@keyframes toLeftFromRight {
  49% {
    transform: translate(-100%);
  }
  50% {
    opacity: 0;
    transform: translate(100%);
  }
  51% {
    opacity: 1;
  }
}
.hovicon.effect-5.sub-c:hover:before {
  -webkit-animation: toTopFromBottom 0.3s forwards;
  -moz-animation: toTopFromBottom 0.3s forwards;
  animation: toTopFromBottom 0.3s forwards;
}

@-webkit-keyframes toTopFromBottom {
  49% {
    -webkit-transform: translateY(-100%);
  }
  50% {
    opacity: 0;
    -webkit-transform: translateY(100%);
  }
  51% {
    opacity: 1;
  }
}
@-moz-keyframes toTopFromBottom {
  49% {
    -moz-transform: translateY(-100%);
  }
  50% {
    opacity: 0;
    -moz-transform: translateY(100%);
  }
  51% {
    opacity: 1;
  }
}
@keyframes toTopFromBottom {
  49% {
    transform: translateY(-100%);
  }
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0