css实现按钮悬浮动画效果代码

代码语言:html

所属分类:悬停

代码描述:css实现按钮悬浮动画效果代码

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

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


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

<head>

  <meta charset="UTF-8">

  
  
  
  
<style>
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@600&display=swap");
* {
  padding: 0;
  margin: 0;
}

body {
  display: flex;
  height: 100vh;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

/********************/
:root {
  --border-width: 5px;
  --green-color: #2cbd52;
  --gray-color: #9a999e;
  --font-size: 1.4rem;
  --font-weight: 600;
  --padding: 4px 30px;
  --width: 230px;
}

.btn {
  width: var(--width);
  margin: 10px;
  font-size: var(--font-size);
  font-weight: var(--font-weight);
  cursor: pointer;
  font-family: Poppins;
  color: var(--gray-color);
  background: transparent;
  padding: var(--padding);
  border-radius: 50px;
  border: var(--border-width) solid var(--gray-color);
  position: relative;
  box-sizing: content-box;
}

.btn .point {
  display: inline-block;
  width: calc(var(--border-width) * 2);
  height: calc(var(--border-width) * 2.6);
  background: var(--gray-color);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: calc(var(--border-width) * -1.2);
  transform: translate(-50%, -50%);
}

/****** regular Button ******/
.btn .topBorder {
  display: inline-block;
  font-size: 0;
  height: calc(var(--border-width) * 0.85);
  position: absolute;
  background: var(--green-color);
  width: 50%;
  top: calc(var(--border-width) * -1);
  right: 30px;
  border-radius: 0 5px 5px 0;
}

.btn .rightCorner {
  position: absolute;
  top: calc(var(--border-width) * -1);
  right: calc(var(--border-width) * -1);
  width: 40%;
  height: 100%;
  background: transparent;
  border-radius: 0 50px 50px 0;
  border-right: var(--border-width) solid var(--green-color);
  border-top: var(--border-width) solid var(--green-color);
  border-bottom: var(--border-width) solid var(--green-color);
}

.wave {
  overflow: hidden;
  width: 102%;
  height: 108%;
  position: absolute;
  top: -2px;
  bottom: -1px;
  left: -1px;
  border-radius: 50px;
}

.btn .wave::after {
  z-index: -1;
  content: "";
  width: 200%;
  height: 100%;
  background: var(--green-color);
  display: block;
  position: absolute;
  left: 130%;
  top: 0;
  transform: skew(45deg);
}

.btn .wave::before {
  z-index: -1;
  content: "";
  width: 200%;
  height: 100%;
  background: var(--gray-color);
  display: block;
  position: absolute;
  left: 110%;
  top: 0;
  transform: skew(45deg);
}

.btn:hover {
  color: #fff;
  border-color: var(--green-color);
  transition: color ease-in-out 0.5s 0.3s, border-color ease-in-out 0.5s 0.3s, background-color ease-in-out 0.3s 0.6s;
}

.btn:hover .point {
  background-color: var(--green-color);
  transition: background-color ease-in-out 0.4s 0.4s;
}

.btn:hover .wave::after {
  transit.........完整代码请登录后点击上方下载按钮下载查看

网友评论0