javascript和css firefox问题

时间:2012-08-13 21:43:46

标签: javascript css css-float

弹出窗口完美适用于chrome,但它不能在Firefox中运行 我已经给了css:float:left;但它没有得到修复

小提琴:http://jsfiddle.net/rajkumart08/s6hBG/21/

CSS:

a{
    text-decoration: none;
    color: inherit;
}


.openme {
    display: inline-block;
    color: #fff;
    background-color: #333;
    padding: 10px;
}

#menu{
    position: absolute;
    padding: 20px 0px 0px;
    background: -webkit-canvas(menu_background) no-repeat;
    -webkit-transition: opacity 300ms ease-out;
    -moz-transition: opacity 300ms ease-out;
}

#menu a{
    float:left;
    margin: 7px;
    padding: 10px 20px;
    font-weight: bold;
    font-size: 20px;
    text-align: center;
    border-radius: 5px;
    background-image: -webkit-gradient(linear, 0% 50%, 0% 51%, from(#fff), to(#edeff3));
    background-image: -moz-linear-gradient(top, #fff, #edeff3);
}

.hide { 
    opacity: 0; 
}

.show {
    opacity: 1;  
}​

2 个答案:

答案 0 :(得分:1)

将此添加到您的CSS:

#moz_background
{
    display:none;
}

并改变这一点:

#menu{
    position: absolute;
    padding: 20px 0px 0px;
    background: -webkit-canvas(menu_background) ;
    -webkit-transition: opacity 300ms ease-out;
    -moz-transition: opacity 300ms ease-out;
}

为:

#menu
{
    position:absolute;
    padding:20px 0px 0px;
    background:-webkit-canvas(menu_background) no-repeat;
    background:-moz-element(#moz_background) no-repeat;
    -webkit-transition:opacity 300ms ease-out;
    -moz-transition:opacity 300ms ease-out;
    transition:opacity 300ms ease-out;
}

<强> DEMO

答案 1 :(得分:0)

这是因为Chrome会将画布显示为div#menu的背景。在Firefox中,实际创建了canvas元素。由于canvas元素显示为block,因此它显示在其前面的a元素下方。