Button Neon HTML & CSS Style 1

Publikasi pada Button tanggal 12 May 2020 oleh Sugeng Sulistiyawan ‐ 3 mnt membaca

Button Neon HTML & CSS Style 1

Button Neon HTML & CSS Style 1.

Button Neon menggunakan HTML & CSS saja.



CSS

:root {
  --dark: #030c26;
  --success: #00c853;
  --warning: #ffab00;
  --danger: #d50000;
}

/* .btn */
.btn {
  cursor: pointer;
  vertical-align: middle;
  text-align: center;
  text-decoration: none;
  font-size: 14px;
  letter-spacing: 2px;
  padding: 10px 18px;
  overflow: hidden;
}

/* .btn.btn-neon */
.btn.btn-neon {
  position: relative;
  display: inline-block;
  border: none;
  background: transparent;
  text-transform: uppercase;
  font-family: "Lucida Sans", "Lucida Sans Regular", "Lucida Grande",
    "Lucida Sans Unicode", Geneva, Verdana, sans-serif;
}

.btn.btn-neon:hover {
  color: #fff !important;
  border-radius: 2px;
  transition: 0.2s;
  transition-delay: 0.8s;
}

.btn.btn-neon > span {
  position: absolute;
  display: block;
}

.btn.btn-neon > span:nth-child(odd) {
  width: 100%;
  height: 2px;
}

.btn.btn-neon > span:nth-child(even) {
  width: 2px;
  height: 100%;
}

.btn.btn-neon > span:nth-child(1) {
  top: 0;
  left: -100%;
}

.btn.btn-neon > span:nth-child(2) {
  right: 0;
  top: -100%;
}

.btn.btn-neon > span:nth-child(3) {
  bottom: 0;
  right: -100%;
}

.btn.btn-neon > span:nth-child(4) {
  left: 0;
  bottom: -100%;
}

.btn.btn-neon:hover > span {
  transition: 0.5s;
}

.btn.btn-neon:hover > span:nth-child(1) {
  left: 100%;
}

.btn.btn-neon:hover > span:nth-child(2) {
  top: 100%;
  transition-delay: 0.2s;
}

.btn.btn-neon:hover > span:nth-child(3) {
  right: 100%;
  transition-delay: 0.4s;
}

.btn.btn-neon:hover > span:nth-child(4) {
  bottom: 100%;
  transition-delay: 0.6s;
}

/* .btn.btn-neon.btn-success */
.btn.btn-neon.btn-success {
  color: var(--success);
}

.btn.btn-neon.btn-success:hover {
  background: var(--success);
  box-shadow: 0 0 10px var(--success), 0 0 20px var(--success),
    0 0 40px var(--success);
}

.btn.btn-neon.btn-success > span:nth-child(1) {
  background: linear-gradient(90deg, transparent, var(--success));
}

.btn.btn-neon.btn-success > span:nth-child(2) {
  background: linear-gradient(180deg, transparent, var(--success));
}

.btn.btn-neon.btn-success > span:nth-child(3) {
  background: linear-gradient(270deg, transparent, var(--success));
}

.btn.btn-neon.btn-success > span:nth-child(4) {
  background: linear-gradient(0deg, transparent, var(--success));
}

/* .btn.btn-neon.btn-warning */
.btn.btn-neon.btn-warning {
  color: var(--warning);
}

.btn.btn-neon.btn-warning:hover {
  background: var(--warning);
  box-shadow: 0 0 10px var(--warning), 0 0 20px var(--warning),
    0 0 40px var(--warning);
}

.btn.btn-neon.btn-warning > span:nth-child(1) {
  background: linear-gradient(90deg, transparent, var(--warning));
}

.btn.btn-neon.btn-warning > span:nth-child(2) {
  background: linear-gradient(180deg, transparent, var(--warning));
}

.btn.btn-neon.btn-warning > span:nth-child(3) {
  background: linear-gradient(270deg, transparent, var(--warning));
}

.btn.btn-neon.btn-warning > span:nth-child(4) {
  background: linear-gradient(0deg, transparent, var(--warning));
}

/* .btn.btn-neon.btn-danger */
.btn.btn-neon.btn-danger {
  color: var(--danger);
}

.btn.btn-neon.btn-danger:hover {
  background: var(--danger);
  box-shadow: 0 0 10px var(--danger), 0 0 20px var(--danger),
    0 0 40px var(--danger);
}

.btn.btn-neon.btn-danger > span:nth-child(1) {
  background: linear-gradient(90deg, transparent, var(--danger));
}

.btn.btn-neon.btn-danger > span:nth-child(2) {
  background: linear-gradient(180deg, transparent, var(--danger));
}

.btn.btn-neon.btn-danger > span:nth-child(3) {
  background: linear-gradient(270deg, transparent, var(--danger));
}

.btn.btn-neon.btn-danger > span:nth-child(4) {
  background: linear-gradient(0deg, transparent, var(--danger));
}

/* Just For Demo */
html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--dark);
  width: 100%;
  height: 100vh;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 10px;
}

HTML

<a href="#" class="btn btn-neon btn-success">
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  Neon Success
</a>
<a href="#" class="btn btn-neon btn-warning">
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  Neon Warning
</a>
<a href="#" class="btn btn-neon btn-danger">
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  Neon Danger
</a>

Demo & Preview:

See the Pen Button Neon 1 by Sugeng Sulistiyawan (@sugeng-sulistiyawan) on CodePen.