Preparati a tuffarti in un mondo di magia e animazioni CSS: questo codice
trasforma i pulsanti in veri protagonisti, regalandogli effetti visivi
sorprendenti che li fanno brillare, pulsare e quasi danzare al passaggio del
mouse! Qui trovi una panoramica degli effetti applicati ai pulsanti.
Effetto “Riflesso” sul Testo dei Link
I pulsanti realizzati con le classi a.ilmiopulsante e
a.ilmiopulsantesfondobianco sfruttano un fantastico
trucco: il background-clip applicato al testo!
-
Gradienti animati:
un gradiente lineare, che sfiora
varie tonalità (da quasi bianco a un azzurro brillante), viene definito e
poi animato grazie alla regola@keyframes riflesso.
Questo crea un effetto di luce che scorre lungo il testo, come se il
pulsante fosse baciato da un riflesso in movimento! -
Transizioni dinamiche:
al passaggio del mouse,
l’animazione si ferma e il colore del testo cambia, dando un feedback visivo
immediato e divertente. Un vero tocco di brio per attirare l’attenzione!
Pulsante 1: stile per sfondo scuro, Glow On Hover.
Il pulsante con la classe .glow-on-hover :
-
Effetto alone:
un pseudo-elemento:beforeviene usato per creare un alone color arcobaleno (con gradienti che
spaziano dal rosso al viola) e, grazie a un filtro blur, il pulsante
sembra emettere una luce pulsante. -
Interazione tattile:
al passaggio del mouse,
l’opacità del alone aumenta, facendo “scoppiare” visivamente il pulsante,
mentre il layer di base (gestito da:after)
garantisce che il design rimanga coeso.
HTML Pulsante 1
CSS Pulsante 1
.glow-on-hover:before {
content: ”;
background: linear-gradient(45deg, #ff0000, #ff7300, #fffb00, #48ff00, #00ffd5, #002bff, #7a00ff, #ff00c8, #ff0000);
position: absolute;
top: -2px;
left:-2px;
background-size: 400%;
z-index: -1;
filter: blur(5px);
width: calc(100% + 4px);
height: calc(100% + 4px);
animation: glowing 20s linear infinite;
opacity: 0;
transition: opacity .3s ease-in-out;
border-radius: 10px;
}
.glow-on-hover:active {
color: #000
}
.glow-on-hover:active:after {
background: transparent;
}
.glow-on-hover:hover:before {
opacity: 1;
}
.glow-on-hover:after {
z-index: -1;
content: ”;
position: absolute;
width: 100%;
height: 100%;
background: #111;
left: 0;
top: 0;
border-radius: 10px;
}
@keyframes glowing {
0% { background-position: 0 0; }
50% { background-position: 400% 0; }
100% { background-position: 0 0; }
}
/* —– FINE Pulsante 1 ——- */
Pulsante 2: L’Arte dell’SVG
Questo pulsante unisce HTML e SVG per un effetto davvero originale:
-
Linea animata: un elemento
<svg>disegna un bordo attorno al pulsante utilizzando le proprietà di
tracciatura del tratto (stroke-dasharrayestroke-dashoffset). -
Animazione fluida: quando l’utente passa con il
mouse, il bordo “si svela” grazie a una transizione che fa scorrere la
linea lungo il perimetro, creando un effetto di disegno in tempo reale.
HTML Pulsante 2
CSS Pulsante 2
.lpbtn {
width: 180px;
height: 60px;
cursor: pointer;
background: transparent;
border: 1px solid #91C9FF;
outline: none;
transition: 1s ease-in-out;
}
svg {
position: absolute;
left: 0;
top: 0;
fill: none;
stroke: #fff;
stroke-dasharray: 150 480;
stroke-dashoffset: 150;
transition: 1s ease-in-out;
}
.lpbtn:hover {
transition: 1s ease-in-out;
background: #4F95DA;
}
.lpbtn:hover svg {
stroke-dashoffset: -480;
}
.lpbtn span {
color: white;
font-size: 18px;
font-weight: 100;
}
/* ----- Pulsante 2 ------- */
Pulsante 3: Semplice ma Efficace
Con la classe .btn-three si punta su un
effetto minimalista ma di grande impatto:
-
Sfumature e trasformazioni:
i
pseudo-elementi::beforee::afteraggiungono sottili sfumature che si trasformano e scalano al
passaggio del mouse, facendo sembrare il pulsante leggero e dinamico. -
Transizioni morbide:
l'intero effetto è gestito con
transizioni che rendono l’animazione fluida e piacevole all’occhio.
HTML Pulsante 3
CSS Pulsante 3
Pulsanti 4 e 5: Il Gran Finale con Bordo Animato
Questi pulsanti, identificati dalle classi .animated-button e .animated-button1, sono un vero
spettacolo:
-
Bordi in movimento:
all’interno di ogni pulsante,
quattro<span>agiscono come “bordi”
animati. Ognuno di essi scorre lungo un lato diverso (alto, destro, basso e
sinistro) grazie a specifiche keyframes (animateTop,animateRight,animateBottom,animateLeft). -
Effetto stratificato:
un pseudo-elemento::beforesovrapposto fornisce una leggera variazione di opacità al passaggio
del mouse, rendendo il tutto ancora più interattivo e vivace. -
Mix di colori:
le varianti dei pulsanti differiscono
nei colori, passando da toni scuri e misteriosi a palette più calde e
vibranti, per adattarsi a diversi contesti e stili.
Pulsante 4
HTML Pulsante 4
CSS Pulsante 4
.animated-button::before {
content: '';
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
background-color: #8592ad;
opacity: 0;
-webkit-transition: .2s opacity ease-in-out;
transition: .2s opacity ease-in-out;
}
.animated-button:hover::before {
opacity: 0.2;
}
.animated-button span {
position: absolute;
}
.animated-button span:nth-child(1) {
top: 0px;
left: 0px;
width: 100%;
height: 2px;
background: -webkit-gradient(linear, right top, left top, from(rgba(8, 20, 43, 0)), to(#2662d9));
background: linear-gradient(to left, rgba(8, 20, 43, 0), #2662d9);
-webkit-animation: 2s animateTop linear infinite;
animation: 2s animateTop linear infinite;
}
@-webkit-keyframes animateTop {
0% {
-webkit-transform: translateX(100%);
transform: translateX(100%);
}
100% {
-webkit-transform: translateX(-100%);
transform: translateX(-100%);
}
}
@keyframes animateTop {
0% {
-webkit-transform: translateX(100%);
transform: translateX(100%);
}
100% {
-webkit-transform: translateX(-100%);
transform: translateX(-100%);
}
}
.animated-button span:nth-child(2) {
top: 0px;
right: 0px;
height: 100%;
width: 2px;
background: -webkit-gradient(linear, left bottom, left top, from(rgba(8, 20, 43, 0)), to(#2662d9));
background: linear-gradient(to top, rgba(8, 20, 43, 0), #2662d9);
-webkit-animation: 2s animateRight linear -1s infinite;
animation: 2s animateRight linear -1s infinite;
}
@-webkit-keyframes animateRight {
0% {
-webkit-transform: translateY(100%);
transform: translateY(100%);
}
100% {
-webkit-transform: translateY(-100%);
transform: translateY(-100%);
}
}
@keyframes animateRight {
0% {
-webkit-transform: translateY(100%);
transform: translateY(100%);
}
100% {
-webkit-transform: translateY(-100%);
transform: translateY(-100%);
}
}
.animated-button span:nth-child(3) {
bottom: 0px;
left: 0px;
width: 100%;
height: 2px;
background: -webkit-gradient(linear, left top, right top, from(rgba(8, 20, 43, 0)), to(#2662d9));
background: linear-gradient(to right, rgba(8, 20, 43, 0), #2662d9);
-webkit-animation: 2s animateBottom linear infinite;
animation: 2s animateBottom linear infinite;
}
@-webkit-keyframes animateBottom {
0% {
-webkit-transform: translateX(-100%);
transform: translateX(-100%);
}
100% {
-webkit-transform: translateX(100%);
transform: translateX(100%);
}
}
@keyframes animateBottom {
0% {
-webkit-transform: translateX(-100%);
transform: translateX(-100%);
}
100% {
-webkit-transform: translateX(100%);
transform: translateX(100%);
}
}
.animated-button span:nth-child(4) {
top: 0px;
left: 0px;
height: 100%;
width: 2px;
background: -webkit-gradient(linear, left top, left bottom, from(rgba(8, 20, 43, 0)), to(#2662d9));
background: linear-gradient(to bottom, rgba(8, 20, 43, 0), #2662d9);
-webkit-animation: 2s animateLeft linear -1s infinite;
animation: 2s animateLeft linear -1s infinite;
}
@-webkit-keyframes animateLeft {
0% {
-webkit-transform: translateY(-100%);
transform: translateY(-100%);
}
100% {
-webkit-transform: translateY(100%);
transform: translateY(100%);
}
}
@keyframes animateLeft {
0% {
-webkit-transform: translateY(-100%);
transform: translateY(-100%);
}
100% {
-webkit-transform: translateY(100%);
transform: translateY(100%);
}
}
/* ----- FINE Pulsante 4 ------- */
Pulsante 5
HTML Pulsante 5
CSS Pulsante 5
.animated-button1::before {
content: '';
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
background-color: #ad8585;
opacity: 0;
-webkit-transition: .2s opacity ease-in-out;
transition: .2s opacity ease-in-out;
}
.animated-button1:hover::before {
opacity: 0.2;
}
.animated-button1 span {
position: absolute;
}
.animated-button1 span:nth-child(1) {
top: 0px;
left: 0px;
width: 100%;
height: 2px;
background: -webkit-gradient(linear, right top, left top, from(rgba(43, 8, 8, 0)), to(#d92626));
background: linear-gradient(to left, rgba(43, 8, 8, 0), #d92626);
-webkit-animation: 2s animateTop linear infinite;
animation: 2s animateTop linear infinite;
}
@keyframes animateTop {
0% {
-webkit-transform: translateX(100%);
transform: translateX(100%);
}
100% {
-webkit-transform: translateX(-100%);
transform: translateX(-100%);
}
}
.animated-button1 span:nth-child(2) {
top: 0px;
right: 0px;
height: 100%;
width: 2px;
background: -webkit-gradient(linear, left bottom, left top, from(rgba(43, 8, 8, 0)), to(#d92626));
background: linear-gradient(to top, rgba(43, 8, 8, 0), #d92626);
-webkit-animation: 2s animateRight linear -1s infinite;
animation: 2s animateRight linear -1s infinite;
}
@keyframes animateRight {
0% {
-webkit-transform: translateY(100%);
transform: translateY(100%);
}
100% {
-webkit-transform: translateY(-100%);
transform: translateY(-100%);
}
}
.animated-button1 span:nth-child(3) {
bottom: 0px;
left: 0px;
width: 100%;
height: 2px;
background: -webkit-gradient(linear, left top, right top, from(rgba(43, 8, 8, 0)), to(#d92626));
background: linear-gradient(to right, rgba(43, 8, 8, 0), #d92626);
-webkit-animation: 2s animateBottom linear infinite;
animation: 2s animateBottom linear infinite;
}
@keyframes animateBottom {
0% {
-webkit-transform: translateX(-100%);
transform: translateX(-100%);
}
100% {
-webkit-transform: translateX(100%);
transform: translateX(100%);
}
}
.animated-button1 span:nth-child(4) {
top: 0px;
left: 0px;
height: 100%;
width: 2px;
background: -webkit-gradient(linear, left top, left bottom, from(rgba(43, 8, 8, 0)), to(#d92626));
background: linear-gradient(to bottom, rgba(43, 8, 8, 0), #d92626);
-webkit-animation: 2s animateLeft linear -1s infinite;
animation: 2s animateLeft linear -1s infinite;
}
@keyframes animateLeft {
0% {
-webkit-transform: translateY(-100%);
transform: translateY(-100%);
}
100% {
-webkit-transform: translateY(100%);
transform: translateY(100%);
}
}
/* ----- FINE Pulsante 5 ------- */
In poche parole, questi codici sono un vero e proprio laboratorio di effetti
per pulsanti, dove ogni blocco di CSS gioca la sua parte per trasformare un
semplice clic in un’esperienza visiva divertente e coinvolgente. È come se
ogni pulsante avesse la sua personalità: pronta a dare quel tocco di magia che
rende il web design così intrigante.