您可以使用jQuery animate,但我认为 css 过渡对于支持它们的浏览器来说看起来更流畅。您可能需要考虑使用条件注释或类似的东西,以便仅在必要时使用脚本。
工作示例
$('.cta').hover(function () {
$(this).removeClass('dark-grey-bg', 800).addClass('blue-bg-fade', 400).animate({
height: $(this).height() * 1.05,
width: $(this).width() * 1.05
}, 300);
$(this).find('a').removeClass('grey').addClass('white').animate({
fontSize: '105%'
}, 300);
}, function () {
$(this).addClass('dark-grey-bg', 400).removeClass('blue-bg-fade', 800).animate({
height: $(this).height() / 1.05,
width: $(this).width() / 1.05
}, 300);
$(this).find('a').removeClass('white', 400).addClass('grey', 800).animate({
fontSize: '100%'
}, 300);
});
这是一个适用于 IE9 及以下版本的条件注释示例
<!--[if lte IE 9]>
// insert script here
<![endif]-->