I remember doing some css learning where i learned to make text-decoration: blink, and the text started blinking.
Now i have a icon,
.iconPM{
background: url(../images/icons/mail_16x16.png) no-repeat;
width: 16px;
height: 16px;
border: none;
display:inline-block;
}
Wonder if i can make this blink, either by simple css or jquery if required. Or maybe any other nice effects available in jquery recommended
JavaScript Code :fadeOut(500); $('. blink'). fadeIn(500); } setInterval(blink_text, 1000); HTML.
When you want to add a blinking animation to an element in your web page, you can use the jQuery fading effects in combination with the JavaScript setInterval() method so that the element will blink once every one or two seconds.
You can add the . blink class to any HTML element to make it blink.
Blink text using jQuery toggleClass() function In this example, we will use the toggleClass() function to toggle between the classes of the selected element, <h1> . This will helps us to produce a blinking effect.
A simple jquery like this would do it:
function blink(){
$('.iconPM').delay(100).fadeTo(100,0.5).delay(100).fadeTo(100,1, blink);
}
$(document).ready(function() {
blink();
});
CSS animations are fairly well supported now, so I thought I'd share a CSS only answer.
.iconPM {
background: url(https://raw.githubusercontent.com/stephenhutchings/typicons.font/493867748439a8e1ac3b92e275221f359577bd91/src/png-24px/mail.png) center no-repeat;
background-size: 16px 16px;
width: 16px;
height: 16px;
border: none;
display:inline-block;
animation: blink 2s ease-in infinite;
}
@keyframes blink {
from, to { opacity: 1 }
50% { opacity: 0 }
}
<span class="iconPM"></span>
What about this?
CSS:
.iconPM.no-image{ background:none; }
JS:
var toggleClassFcn = function(){$(".iconPM").toggleClass("no-image");}
setInterval(toggleClassFcn, 300);
Just be careful as with any other animations on the page. It will consume thread on the page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With