Jump to content
Search Community

david_41980

Members
  • Posts

    1
  • Joined

  • Last visited

david_41980's Achievements

0

Reputation

  1. Note: The following does not work in IE8 I came across this just the other day, but the solution I was looking for would ideally not have me define the background colour in both the CSS and JavaScript. In the end I managed to solve it by using the "getComputedStyle" function, and then modifying the alpha value as required. In my scenario I was trying to fade in the background: #el { background-color: #000; } var $el = document.getElementById('#el'), bgColor = getComputedStyle($el)['background-color'], fromBgColor = bgColor.substr(0, bgColor.length - 1) + ', 0)'; TweenLite.from($el, 0.3, { backgroundColor: fromBgColor }); For this to work I'm working on the assumption that "getComputedStyle" will return me an rgb string for the background colour. I'm currently trying to figure out whether this is a safe assumption to make.
×
×
  • Create New...