4 replies [Last post]
gautamz07
gautamz07's picture
Offline
Enthusiast
Last seen: 3 years 7 weeks ago
Timezone: GMT+5.5
Joined: 2014-04-24
Posts: 265
Points: 403

Now i have a stylesheet called animations, and in that i have the following code:

.arrowInfiniteAnim {
  -webkit-animation-duration: .5s;
  -o-animation-duration: .5s;
  animation-duration: .5s;
  -webkit-animation-direction: alternate;
  -o-animation-direction: alternate;
  animation-direction: alternate;
  -webkit-animation-iteration-count: infinite;
  -o-animation-iteration-count: infinite;
  animation-iteration-count: infinite;
  -webkit-animation-name: arrowInfiniteAnim;
  animation-name: arrowInfiniteAnim;
}

Now suppose when i use the above class in practice i would like the size of the element to be 3em, So in my main stylesheet i add the following code:

.arrowInfiniteAnim {
  font-size : 3em;  
}

So my question is , is it correct to define rules for the same class in multiple style sheets ?

Thank you.

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 1 week 6 days ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5342
Points: 2963

Hi gautamz07, Yes it is

Hi gautamz07,
Yes it is correct and good practice as long as you have clearly defined the purpose of each stylesheet.
For example:
layout.css
animation.css
content.css
...

gautamz07
gautamz07's picture
Offline
Enthusiast
Last seen: 3 years 7 weeks ago
Timezone: GMT+5.5
Joined: 2014-04-24
Posts: 265
Points: 403

Tony yes thanks

One of the reason i have a separate stylesheet for animations is , they tend to run into a few hundreds of lines. I just wanted to keep the animations separate. Thanks for confirming .

Have a nice day Laughing out loud

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 13 hours 38 min ago
Dallas
Timezone: GMT-6
Joined: 2004-06-25
Posts: 9743
Points: 3822

Now, for a different opinion

My experience comes from primarily the maintenance and debugging point of view. If you realize that those two factors (in a non-trivial site) cost one and one-half to two times the original development costs per annum, you'll see that making everything human readable, from organization to formatting is critical to keeping costs down.

I find that writing your stylesheets, grouping contextually does save that time and effort. A positive side effect is that you will be less likely to unintentionally write conflicting style rules; not to mention that order of loading the stylesheets becomes an issue in the cascade order.

Contextual stylesheets do require that you pre-plan your rulesets; you can't just throw them in any old place, as can easily happen with multiple files.

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

gautamz07
gautamz07's picture
Offline
Enthusiast
Last seen: 3 years 7 weeks ago
Timezone: GMT+5.5
Joined: 2014-04-24
Posts: 265
Points: 403

Contextual stylesheets

Contextual stylesheets ... yeah thats the right word , so you think its a good thing or a bad thing ? ... i think its a great idea and helps me keep things organized.