div+css实现十几种按钮悬浮动画效果集合代码

代码语言:html

所属分类:悬停

代码描述:div+css实现十几种按钮悬浮动画效果集合代码

代码标签: div css 按钮 悬浮 动画

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

<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/all.5.11.2.css">
<style>
    @charset "UTF-8";
@import url(https://fonts.googleapis.com/css?family=Lato);
body {
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: #222;
}

.btn {
  --hue: 190;
  position: relative;
  padding: 0.375rem 0.75rem;
  margin: 1rem;
  font-size: 1rem;
  line-height: 1.5;
  color: white;
  text-decoration: none;
  background-color: hsl(var(--hue), 100%, 41%);
  border: 1px solid hsl(var(--hue), 100%, 41%);
  border-radius: 3px;
  outline: transparent;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: 0.25s;
}
.btn:hover {
  background: hsl(var(--hue), 100%, 31%);
}
.btn-primary {
  --hue: 171;
}
.btn-ghost {
  color: hsl(var(--hue), 100%, 41%);
  background-color: transparent;
}
.btn-ghost:hover {
  color: white;
  background: hsl(var(--hue), 100%, 41%);
}
.btn-jittery {
  animation: jittery 4s infinite;
}
.btn-finger {
  overflow: visible;
}
.btn-finger::before {
  position: absolute;
  content: "👇";
  top: -68px;
  right: 0;
  font-size: 60px;
  transform: scaleX(-1);
  animation: up-down 1s infinite;
}
.btn-icon {
  position: relative;
  margin-left: 8px;
}
.btn-icon i {
  position: absolute;
  top: 10%;
  left: 40%;
  transform: translate(-16%, 400%);
  transition: 0.2s;
}
.btn-icon span {
  display: flex;
  justify-content: center;
  align-items: center;
  transition: 0.2s;
}
.btn-icon:hover i {
  transform: translate(-16%, 42%);
}
.btn-icon:hover span {
  transform: translateY(-400%);
}
.btn-jelly:hover {
  animation: jelly 0.5s;
}
.btn-fill:hover {
  background: transparent;
  box-shadow: 0 0 0 2em hsl(var(--hue), 100%, 41%) inset;
}
.btn-pulse:hover {
  box-shadow: 0 0 0 1em transparent;
  animation: pulse 1s;
}
.btn-shock {
  background: transparent;
  border-color: transparent;
  overflow: visible;
}
.btn-shock:hover {
  background: transparent;
}
.btn-shock::before, .btn-shock::after {
  position: absolute;
  content: "";
  top: -1px;
  left: -1px;
  right: -1px;
  bottom: -1px;
  border: inherit;
  border-radius: inherit;
  transition: 0.3s;
}
.btn-shock::before {
  z-index: -1;
  background: hsl(var(--hue), 100%, 41%);
}
.btn-shock::after {
  z-index: -2;
  background: #222;
  border-color: hsl(var(--hue), 100%, 41%);
  transform: scale(0.5);
}
.btn-shock:hover {
  color: hsl(var(--hue), 100%, 41%);
}
.btn-shock:hover::before {
  opacity: 0;
  transform: scale(1.2);
}
.btn-shock:hover::after {
  transform: scale(1);
}
.btn-open::before {
  position: absolute;
  content: "";
  top: 0;
  left: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  background: hsl(var(--hue), 100%, 41%);
  transform: scaleX(0);
  transition: 0.25s;
}
.btn-open:hover {
  background: transparent;
}
.btn-open:hover::before {
  transform: scaleX(1);
}
.btn-close:hover {
  background: transparent;
  box-shadow: inset 3em 0 0 0 hsl(var(--hue), 100%, 41%), inset -3em 0 0 0 hsl(var(--hue), 100%, 41%);
}
.btn-slash::before {
  position: absolute;
  content: "";
  top: 50%;
  left: 50%;
  z-index: -1;
  width: 120%;
  height: 200%;
  background: hsl(var(--hue), 100%, 41%);
  transform: translate(-50%, -50%) rotate(-45deg) scaleX(0);
  transition: 0.25s;
}
.btn-slash:hover {
  background: transparent;
}
.btn-slash:hover::before {
  transform: translate(-50%, -50%) rotate(-45deg) scaleX(1);
}
.btn-fill-up:hover {
  background: transparent;
  box-shadow: inset 0 -3em 0 0 hsl(var(--hue), 100%, 41%);
}
.btn-slide:hover {
  background: transparent;
  box-shadow: inset 4em 0 0 0 hsl(var(--hue), 100%, 41%);
}
.btn-offset {
  border-radius: 0;
  box-shadow: 0.3em 0.3em 0 0 hsl(var(--hue), 100%, 41%), inset 0.3em 0.3em 0 0 hsl(var(--hue), 100%, 41%);
}
.btn-offset:hover {
  --hue: 196;
  background: transparent;
  box-shadow: 0 0 0 0 hsl(var(--hue), 100%, 41%), inset 6em 4em 0 0 hsl(var(--hue), 100%, 41%);
}
.btn-flip-down {
  --flip-button-height:40px;
  height: var(--flip-button-height);
  color: transparent;
  border: none;
  border-radius: 0;
  perspective: 500px;
  overflow: visible;
}
.btn-flip-down:hover {
  color: transparent;
  background: transparent;
}
.btn-flip-down .front,
.btn-flip-down .back {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}
.btn-flip-down .front {
  background: hsl(var(--hue), 100%, 41%);
  color: white;
  transition: 0.25s;
  transform-origin: center center calc(var(--flip-button-height) / -2);
}
.btn-flip-down .back {
  --hue: 196;
  color: white;
  background: hsl(var(--hue), 100%, 41%);
  transform: rotateX(88deg);
  transform-origin: center center calc(var(--flip-button-height) / -2);
  transition: 0.25s;
}
.btn-flip-down:hover .front {
  transform: rotateX(-90deg);
}
.btn-flip-down:hover .back {
  transform: rotateX(0deg);
}
.btn-breach {
  border-width: 4px;
  border-radius: 0;
  overflow: visible;
}
.btn-breach::before, .btn-breach::after {
  position: absolute;
  content: "";
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0