Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8904689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:11:50+00:00 2026-06-15T02:11:50+00:00

div { width:100px; height:100px; background:red; animation:myfirst 3s; -moz-animation:myfirst 3s; /* Firefox */ -webkit-animation:myfirst 3s;

  • 0
div
{
width:100px;
height:100px;
background:red;
animation:myfirst 3s;
-moz-animation:myfirst 3s; /* Firefox */
-webkit-animation:myfirst 3s; /* Safari and Chrome */
-webkit-animation-iteration-count: infinite;
-moz-animation-iteration-count: infinite;
}


@-webkit-keyframes myfirst /* Safari and Chrome */
{
0% {background:red;}
50% {background:#800000;}
100% {background:red;}
}

See my jsFiddle (DOES NOT WORK WITH IE OR OPERA). Or see the CSS above.

Its a simple color animation that goes from red to dark red, and back to red. I need to make it such that when the button is clicked it will go from:

blue to #000066 and then back to blue.

I know one method is to create a new style sheet and switch stylesheets but,

(1) I’m not quite sure how to do that

and

(2) In the grand scheme of all of this I need to repeat this about 15 times with different colors, I would hate to have 15 different stylesheets for colors. Is there a JQuery or straight up javascript way of doing this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:11:51+00:00Added an answer on June 15, 2026 at 2:11 am

    No need to create a new stylesheet. Just create a different class for each color, and use jQuery to .addClass() and .removeClass():

    function blueMe(){
      $('div').removeClass().addClass('blue');
    }​
    

    http://jsfiddle.net/mblase75/KHnBz/6/

    As you’ll see in the CSS for that fiddle, you’ll need to create new keyframes for each class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This works great: <style type=text/css> div { width:100px; height:100px; background:red; transition:width 2s; -moz-transition:width 2s;
the body html code: <div style=background:yellow;width:500px;height:300px;> <div id=div1 style=background:red; width:100px;height:100px; float:left;></div> <div id=div2 style=background:blue;
i have the following html code <div style=background-color:Red;width:100px;height:100px;padding:5px;> <input type=text class=text id=txtExtraSubject style=width:450px;/> </div>
this is my code : <div id=test style=width:200px;height:100px;background:red class=tabs change_font_size> <div> <a class=delete style=float:right;font-size:20px;text-decoration:underline;cursor:pointer;>delete</a>
<style type=text/css> #box { background: red; width: 100px; height: 100px; color: #fff; line-height: 100px;
my html code <div id=content_main></div> css #content_main { width:1024px; height:150px; background:url('../images/Orange.jpg'); background-repeat:no-repeat; background-size:1024px 150px;
my code <div id=header> <div id=header_top>KIDS'<br>ZONE</div> </div> css #header{ width:1024px; height:150px; background:url('../images/Orange.jpg'); background-repeat:no-repeat; background-size:1024px
my CSS code .child{ width:100px; height:100px; display:inline-block; } my HTML code <div id=parent> <div
I've a div having height and width as 100px respectively. When I zoom in
I have the following markup: <div style=overflow:auto;width:500px;height:100px;> <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.