• Страница 1 из 1
  • 1
Форум » Веб-разработка » HTML + CSS — коды » Красивое решение CSS-анимации для кнопок (Стильный эффект для кнопок на эффекте при наведении)
Красивое решение CSS-анимации для кнопок
Kosten
Вторник, 26 Октября 2021 | Сообщение 1
Оффлайн
Администраторы
Сообщений:44356
Награды: 70
Сейчас очень стильно устанавливать на сайт, те кнопки, что пе имеют основного каркаса, а точнее мы наблюдаем красиво исполненный обвод, которому закреплен эффект, что будет происходит при наведении на кнопку. Сами кнопки по умолчанию идут в темном оттенке, но стилистика, что закреплена за HTML может решить по установлению разной гаммы цвета.

По умолчанию:



С наведением курсора:



Установка:

HTML

Код
<div id="animatsa-knopoca" class="animatsa-knopoca">
    <button id="kadesa" class="kesa"><span>ZorNet.Ru #1</span></button>
    <button id="vadesa" class="vesa"><span>ZorNet.Ru #2</span></button>
    <button id="gadesa" class="desa"><span>ZorNet.Ru #3</span></button>
  </div>

CSS

Код
button {
  cursor: pointer;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-family: Marvel;
  font-size: 20pt;
  width: 200px;
  height: 45px;
  position: relative;
  border: solid #bbb 2px;
  color: #bbb;
  z-index: 1;
  transition: all 0.5s ease-in-out;
  border-radius: 5px;
  margin: 5px;
}
button:focus {
  outline: none;
}
.animatsa-knopoca {
  width: 852px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 0px;
}
.kesa {
  background: #333;
}
.kesa:before {
  content: "";
  width: 0%;
  height: 100%;
  position: absolute;
  top: 0;
  right: 50%;
  background-color: red;
  transition: 0.5s ease-in-out;
  z-index: -1;
}
.kesa:hover:before {
  width: 100%;
  right: 0%;
}
.kesa:hover {
  color: #f1f1f1;
  border-color: red;
}
.kesa:active {
  color: #333;
  border-color: #00a7fc;
  background-color: #00a7fc;
}
.kesa:active:before {
  background-color: #00a7fc;
}

.vesa {
  cursor: pointer;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-family: Marvel;
  font-size: 20pt;
  width: 200px;
  height: 45px;
  position: relative;
  color: #bbb;
  z-index: 1;
  transition: all 0.5s ease-in-out;
  border-radius: 0px;
  margin: 5px;
  background: transparent;
  padding: 0;
  overflow: hidden;
  border: none;
}
.vesa:before {
  content: "";
  position: absolute;
  bottom: 0;
  right: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(to left, transparent, #bbb);
  animation: vesa-left 2s linear infinite;
  transition: 0.5s ease-in-out;
}
.vesa:after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 2px;
  height: 100%;
  background: linear-gradient(to top, transparent, #bbb);
  animation: vesa-top 2s linear infinite;
  animation-delay: 1s;
  transform: translateY(-100%);
}
.vesa span {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 6px;
}
.vesa span:after {
  content: "";
  position: absolute;
  top: 0px;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(to right, transparent, #bbb);
  animation: vesa-right 2s linear infinite;
}
.vesa span:before {
  content: "";
  position: absolute;
  top: 0px;
  right: 12px;
  width: 2px;
  height: 100%;
  background: linear-gradient(to bottom, transparent, #bbb);
  animation: desa-bottom 2s linear infinite;
  animation-delay: 1s;
  transform: translateY(-100%)
}
.vesa:hover:before {
  background: linear-gradient(to left, transparent, red);
}
.vesa:hover:after {
  background: linear-gradient(to top, transparent, red);
}
.vesa span:hover:before {
  background: linear-gradient(to bottom, transparent, red);
}
.vesa span:hover:after {
  background: linear-gradient(to right, transparent, red);
}
.vesa:hover {
  color: red;
}
.vesa:active:before {
  background: linear-gradient(to left, transparent, #00a7fc);
}
.vesa:active:after {
  background: linear-gradient(to top, transparent, #00a7fc);
}
.vesa span:active:before {
  background: linear-gradient(to bottom, transparent, #00a7fc);
}
.vesa span:active:after {
  background: linear-gradient(to right, transparent, #00a7fc);
}
.vesa:active {
  color: #00a7fc;
}
@keyframes vesa-top {
  0% {
    transform: translateY(100%);
  }
  100% {
    transform: translateY(-100%);
  }
}
@keyframes vesa-left {
  0% {
    transform: translateX(100%);
  }
  100% {
    transform: translateX(-100%);
  }
}
@keyframes vesa-bottom {
  0% {
    transform: translateY(-100%);
  }
  100% {
    transform: translateY(100%);
  }
}
@keyframes vesa-right {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.desa {
  cursor: pointer;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-family: Marvel;
  font-size: 20pt;
  width: 200px;
  height: 45px;
  position: relative;
  color: #bbb;
  z-index: 1;
  transition: all 0.5s ease-in-out;
  border-radius: 0px;
  margin: 5px;
  background: transparent;
  padding: 0;
  overflow: hidden;
  border: none;
}
.desa:before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(to left, transparent, #bbb);
  animation: desa-left 2s linear infinite;
  transition: 0.5s ease-in-out;
}
.desa:after {
  content: "";
  position: absolute;
  bottom: 0;
  right: 0;
  width: 2px;
  height: 100%;
  background: linear-gradient(to top, transparent, #bbb);
  animation: desa-top 2s linear infinite;
  animation-delay: 1s;
  transform: translateY(-100%);
}
.desa span {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 6px;
}
.desa span:after {
  content: "";
  position: absolute;
  bottom: 12px;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(to right, transparent, #bbb);
  animation: desa-right 2s linear infinite;
}
.desa span:before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 100%;
  background: linear-gradient(to bottom, transparent, #bbb);
  animation: desa-bottom 2s linear infinite;
  animation-delay: 1s;
  transform: translateY(-100%)
}
.desa:hover:before {
  background: linear-gradient(to left, transparent, red);
}
.desa:hover:after {
  background: linear-gradient(to top, transparent, red);
}
.desa span:hover:before {
  background: linear-gradient(to bottom, transparent, red);
}
.desa span:hover:after {
  background: linear-gradient(to right, transparent, red);
}
.desa:hover {
  color: red;
}
.desa:active:before {
  background: linear-gradient(to left, transparent, #00a7fc);
}
.desa:active:after {
  background: linear-gradient(to top, transparent, #00a7fc);
}
.desa span:active:before {
  background: linear-gradient(to bottom, transparent, #00a7fc);
}
.desa span:active:after {
  background: linear-gradient(to right, transparent, #00a7fc);
}
.desa:active {
  color: #00a7fc;
}
@keyframes desa-top {
  0% {
    transform: translateY(100%);
  }
  100% {
    transform: translateY(-100%);
  }
}
@keyframes desa-left {
  0% {
    transform: translateX(100%);
  }
  100% {
    transform: translateX(-100%);
  }
}
@keyframes desa-bottom {
  0% {
    transform: translateY(-100%);
  }
  100% {
    transform: translateY(100%);
  }
}
@keyframes desa-right {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

Установка завершена!

Демонстрация
Прикрепления: 7438866.png (9.6 Kb) · 2456652.png (8.9 Kb) · button-animatio.zip (4.4 Kb)
Страна: (RU)
Форум » Веб-разработка » HTML + CSS — коды » Красивое решение CSS-анимации для кнопок (Стильный эффект для кнопок на эффекте при наведении)
  • Страница 1 из 1
  • 1
Поиск: