0

Given below is a snippet from an alistapart article. But the transition on "focus" (click) doesn't seems to be working on Chrome(25.0.1364.172) and Firefox(19.0.2). But works with Opera(12.14) (On Linux).

Any idea why?

<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
a.foo {
  padding: 5px 10px;
  background: #9c3;
  -webkit-transition: background 0.3s ease;
  -moz-transition: background 0.3s ease;
  -o-transition: background 0.3s ease;
  transition: background 0.3s ease;
}
a.foo:hover,
a.foo:focus {
  background: #690;
}
</style>
</head>
<body>
<a href="#" class="foo">Transition me!
</body>
</html>
Dbob
  • 67
  • 6

2 Answers2

1

Not sure why it's not working on Chrome, but can try with "onclick" event instead of pseudo class. Something like below should give you same effect on Chrome and others.

Also it's recommended to use 'onclick' and similar events instead of Pseudo classes.

http://jsfiddle.net/RFauS/

<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
a.foo {
  padding: 5px 10px;
  background: #9c3;
  -webkit-transition: background 0.3s ease;
  -moz-transition: background 0.3s ease;
  -o-transition: background 0.3s ease;
  transition: background 0.3s ease;
}

a.foo_clicked {
  padding: 5px 10px;
  background: #690;
  -webkit-transition: background 0.3s ease;
  -moz-transition: background 0.3s ease;
  -o-transition: background 0.3s ease;
  transition: background 0.3s ease;
}

a.foo:hover
{  background: #690;
}
</style>
</head>
<body>
<a href="#" class="foo" onclick="this.className='foo_clicked';" tabindex="0" onBlur="this.className='foo';" >Transition me!</a>
</body>
</html>
sojin
  • 4,527
  • 2
  • 37
  • 40
0

Please check on this page & especially this page the compatibility. Transition in CSS is ok from chrome 26.0, firefox 16 and opera 12.10

clement
  • 4,204
  • 10
  • 65
  • 133
  • But transition on :hover works with Chrome 25. Shouldn't that be working on 25 as well ? Or may be multiple trigger might not work. – Dbob Mar 14 '13 at 15:14
  • This is irrelevant. He's using `-webkit-transition` which has been supported in Chrome since 1.0, `-mox-...` which has been supported in Firefox since 4.0 and `-o-...` which has been supported in Opera since 10.5. – James Donnelly Mar 14 '13 at 15:14