!important in CSS

 I used '!important' in CSS for the first time.


Only to discover that you are not meant to use it because it is difficult to override.


I have a problem where an element has a 'transition' on both 'color' and 'transform' but these attributes are set in different places and may or may not be present.


I set the transitions by creating dynamic stylesheets with JavaScript so the latest 'transition' overrides the earlier. 


I tried using 'id' and 'class' CSS selectors so the earlier 'id' overrides the later 'class' selector but I cannot do this easily in all places because I am changing old code.


So I set: 'transition: color 3s, transform 0.5s !important' to override where I later set 'transition: transform 0.5s'


There are more tips at: [bbingo.xyz/t](http://bbingo.xyz/t)


There are more tips at: bbingo.xyz/techtips/

Comments

Popular posts from this blog

webkit-tap-highlight-color in CSS

Steve Jobs quotes