작업 일지/HTML CSS

부드러운 버튼 만들기- 마우스오버

AI랑노는 또또 2024. 3. 19. 16:08

 

HTML

<div class="button-box">
    <button class="btn">HELLO</button>
    <button class="btn2">slide</button>
    <button class="btn3">hover</button>
</div>



CSS

/* 버튼 */
.button-box {
  /* height: 100vh; */
  /* display: flex;
  justify-content: center;
  align-items: center; */
}
.button-box .btn {
  font-size: 25px;
  padding: 15px 30px;
  color: #000;
  border: 3px solid #000;
  border-radius: 30px;
  text-transform: uppercase;
  letter-spacing: 4px;
  transition: all 0.4s;
}
.button-box .btn:focus {
  outline: none;
}
.button-box .btn:hover {
  background-color: #000;
  color: #fff;
}

/* slide button btn2 */
.button-box .btn2 {
  font-size: 25px;
  padding: 15px 30px;
  border: 3px solid gold;
  background-color: #a1a1a1;
  color: gold;
  text-transform: uppercase;
  letter-spacing: 5px;
  font-weight: bold;
  position: relative;
  transition: all 0.4s;
  overflow: hidden;
  z-index: 1;
}
.button-box .btn2:focus {
  outline: none;
}
.button-box .btn2::before {
  content: "";
  position: absolute;
  height: 100%;
  width: 100%;
  background-color: gold;
  top: 100%;
  left: 0;
  transition: all 0.4s;
  z-index: -1;
}
.button-box .btn2:hover::before {
  transform: translateY(-100%);
}
.button-box .btn2:hover {
  color: #0f0f0f;
}

 

hover line

/* hover line */
.button-box .btn3 {
  font-size: 25px;
  padding: 15px;
  border: 0;
  background-color: transparent;
  letter-spacing: 0;
  -webkit-transition: all 0.28s ease-in-out;
  transition: all 0.28s ease-in-out;
}
.button-box .btn3:focus {
  outline: none;
}
.button-box .btn3:hover,
.button-box .btn3:focus,
.button-box .btn3:active {
  letter-spacing: 5px;
}
.button-box .btn3:after,
.button-box .btn3:before {
  border: 1px solid rgba(255, 255, 255, 0);
  bottom: 0;
  content: " ";
  display: block;
  margin: 0 auto;
  position: relative;
  -webkit-transition: all 0.28s ease-in-out;
  transition: all 0.28s ease-in-out;
  width: 0;
}
.button-box .btn3:hover:after,
.button-box .btn3:hover:before {
  border-color: #e00303;
  -webkit-transition: width 350ms ease-in-out;
  transition: width 350ms ease-in-out;
  width: 70%;
}
.button-box .btn3:hover:before {
  bottom: auto;
  top: 0;
}