Moderators Note - you've been on the forum a while now so please remember to use the BB code buttons to format your code otherwise persistent failure to do so may result in the issue of infraction points.
Formatting your code helps with the readability of a post, and can affect response time (posts that are easier to read tend to be answered faster)
If you are unsure which formatting button to use, or if you are in the 'Quick Reply' window, head for the hash '#' - when you hover over it, a tooltip appears saying "Wrap [CODE] tags around selected text".
I've moved your thread from the Java to the CSS forum, because these animations are done using CSS3.
Here are CSS3 animations for approx 1-second and 2-second flashes;
CSS
Code:
#one-sec {
animation: one-sec 1500ms linear infinite;
-moz-animation: one-sec 1500ms linear infinite;
-webkit-animation: one-sec 1500ms linear infinite;
-o-animation: one-sec 1500ms linear infinite;
text-align: center;
}
@keyframes one-sec { 0% {opacity:0;} 10% {opacity:1;} 90% {opacity:1;} 100% {opacity:0;} }
@-moz-keyframes one-sec { 0% {opacity:0;} 10% {opacity:1;} 90% {opacity:1;} 100% {opacity:0;} }
@-webkit-keyframes one-sec { 0% {opacity:0;} 10% {opacity:1;} 90% {opacity:1;} 100% {opacity:0;} }
@-o-keyframes one-sec { 0% {opacity:0;} 10% {opacity:1;} 90% {opacity:1;} 100% {opacity:0;} }
#two-sec {
animation: two-sec 2500ms linear infinite;
-moz-animation: two-sec 2500ms linear infinite;
-webkit-animation: two-sec 2500ms linear infinite;
-o-animation: two-sec 2500ms linear infinite;
text-align: center;
}
@keyframes two-sec { 0% {opacity:0;} 10% {opacity:1;} 90% {opacity:1;} 100% {opacity:0;} }
@-moz-keyframes two-sec { 0% {opacity:0;} 10% {opacity:1;} 90% {opacity:1;} 100% {opacity:0;} }
@-webkit-keyframes two-sec { 0% {opacity:0;} 10% {opacity:1;} 90% {opacity:1;} 100% {opacity:0;} }
@-o-keyframes two-sec { 0% {opacity:0;} 10% {opacity:1;} 90% {opacity:1;} 100% {opacity:0;} }
HTML
Code:
<div id="one-sec">** PUT YOUR TEXT TO FLASH HERE - APPROX 1 SECOND VISIBLE BETWEEN FLASHES **</div>
<div id="two-sec">** PUT YOUR TEXT TO FLASH HERE - APPROX 2 SECONDS VISIBLE BETWEEN FLASHES **</div>
The time sequence for each animation is highlighted red.
As for extending the time that the text is visible for, that needs to be done with the keyframes, highlighted blue - change to full opacity at around the 10% mark in the animation sequence, and then change back to 0 opacity from the 90% mark, makes the text visible for roughly 80% of the time during each animation loop (well, a bit less if you take out the time for the actual colour transition).
EDIT: I've also added Opera-specific definitions with the "-o-" vendor prefix, just to make sure you're covered there.
Bookmarks