【发布时间】:2013-09-04 05:13:00
【问题描述】:
所以,我在 .image-wrapper 中有一个 img 标签,我想在悬停时向下平移。 CSS3 过渡的基本用法 - 基于此处:http://designshack.net/articles/css/joshuajohnson-2/
这是我的手写笔代码:
// Portfolio
.portfolio-wide
.image-wrapper
height 300px
overflow hidden
.portfolio-wide
.image-wrapper img
width 100%
margin-top 0px
transition all 10s ease
.portfolio-wide
.image-wrapper:hover img
margin-top -100%
Stylus 和 Nib 将其转换为带有所有浏览器特定内容的 CSS。
我的问题是 IE
如何在 Stylus 中做到这一点?似乎很常见,但我找不到示例或文档。
建议?我尝试了一些 jQuery CoffeeScript 在页面加载时添加/删除样式,但没有成功。
$(document).ready ->
# Like I don't have better things to do IE...
# determine if the browser supports transition
thisStyle = document.body.style
supportsTransition = true
(thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.OTransition !== undefined || thisStyle.transition !== undefined)
alert supportsTransition
# assign jQuery transition if the browser doesn't support
$if ( supportsTransition )
alert "here"
$(".portfolio-wide .image-wrapper:hover img").css('margin-top', '-100%')
警报发生在正确的时间,但我没有在代码中看到正确的效果。在上面的代码中,没有添加 margin-top 样式,所以没有发生过渡。我尝试在 !supportsTranstion 上删除 .css('margin-top', '0px'),但没有成功。
无论如何,这对 IE 来说是个麻烦事,我只想禁用它。有什么建议吗?
谢谢!
迈克
【问题讨论】:
标签: jquery css coffeescript css-transitions stylus