Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make text blink on website? [duplicate]

Tags:

html

css

I am making a website and I want a hyperlink on the page to blink. It doens't matter how fast it does, only not too slow. It would also be cool if I could make it blink in different colors.

I have tried using text-decoration:blink; in css, but that didn't work.

I've added this to the css-file, but now what?:

blink {
-webkit-animation-name: blink; 
-webkit-animation-iteration-count: infinite; 
-webkit-animation-timing-function: cubic-bezier(1.0,0,0,1.0);
-webkit-animation-duration: 1s;
}

Doesn't seem to work

like image 775
Commodent Avatar asked Nov 28 '13 15:11

Commodent


People also ask

How do I make text blink on a website?

The HTML <blink> tag is used to create a blinking text that flashes slowly.

How do you blink a text?

Blink Tag in HTMLThe HTML blink tag is a non-standard element of HTML that helps to flash or gently blink a text or set of text in a web browser; as you all might know, Blink means turning on and off any light in a regular pattern or within a fixed time interval.

How do you make words blink?

Place your cursor next to the last letter in the text, type additional text and that text will blink as well because it becomes part of the same text block. Right-click the text and click the arrow next to “Text Highlight Color” to view a list of highlight colors.


2 Answers

You can do this pretty easily with CSS animations.

a {   
  animation-duration: 400ms;
  animation-name: blink;
  animation-iteration-count: infinite;
  animation-direction: alternate;
}

@keyframes blink {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

You can also extend it to change colors. With something like:

@keyframes blink {
  0% {
    opacity: 1;
    color: pink;
  }

  25% {
    color: green;
    opacity: 0;
  }

  50% {
    opacity: 1;
    color: blue;
  }

  75% {
   opacity: 0;
   color: orange;
 }

 100% {
   opacity: 1;
   color: pink;
 }
}

Make sure to add vendor prefixes

Demo: http://codepen.io/pstenstrm/pen/yKJoe

Update

To remove the fading effect you can do:

b {
  animation-duration: 1000ms;
  animation-name: tgle;
  animation-iteration-count: infinite;
}

@keyframes tgle {
  0% {
    opacity: 0;
  }

  49.99% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }

  99.99% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

This is also a useful trick when animating image-sprites

like image 198
pstenstrm Avatar answered Sep 22 '22 15:09

pstenstrm


Its easy to make a text blink:

window.setInterval(function() {
$('#blinkText').toggle();
}, 300);

and in html, just give as follows:

<p id="blinkText">Text blinking</p>
like image 32
Nit Avatar answered Sep 20 '22 15:09

Nit