Reputation: 67
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>
Upvotes: 0
Views: 1470
Reputation: 4694
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.
<!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>
Upvotes: 1