jquery&CSS - Z-index

San*_*ket 6 css jquery z-index

在下面的jquery函数中,z-index在IE7中不起作用,请帮帮我

<script>
$(function() {
    $('span').hover(function() {

        $(this).stop().css({                      
            'float': 'left',
        'z-index':'15'
        }).animate({
            marginTop: '0px',
            marginLeft: '0px',            
            width: '200px',
            height: '125px',
            padding: '0px'

        }, 700, 'swing');


    }, function() {

        $(this).stop().css({            
            'border': '0px',
            'z-index':'10'
        }).fadeIn('slow').animate({
            marginTop: '0px',
            marginLeft: '0px',            
            width: '40px',
            height: '13px'            
        }, 700, 'swing');


    });
});

</script>
Run Code Online (Sandbox Code Playgroud)

非常感谢.我是jquery的新手.

Jas*_*aro 5

它只在IE7中?

看起来问题出float:left在第一个问题上function.

据我所知,z-index只适用于定位元素. Floats没有定位,因此无法接受z-index.请参见http://reference.sitepoint.com/css/z-index

如果可能,请移除float并以span另一种方式定位.


Lia*_*iam 2

有关此错误的示例,请参阅http://www.brenelz.com/blog/2009/02/03/squish-the-internet-explorer-z-index-bug/ 。您必须为父元素提供更高的 z-index 才能使其正常工作。