日期:2014-05-17  浏览次数:20557 次

隐藏显示左侧边栏,要兼容ie6、7,折腾人啊
从网上找了高度100%并兼容ie6的css代码,如下

  html, body
{
    overflow: hidden;
    padding: 0;
    margin: 0;
    height: 100%;
    font-size: 12px;
}
div
{
    position: absolute;
}
#left
{
    left: 0;
    top: 0;
    bottom: 0; /*不加这个滚动条居然不出来*/
    width: 150px; /* 宽度与switchBar、main及js控制脚本有关*/
    overflow: auto;
    background-image: url(../Images/navshape.jpg);
    background-repeat: no-repeat;
    background-color: #84B1EC;
}
#switchBar
{
    top: 0;
    left: 150px;
    bottom: 0; /*不加这个滚动条居然不出来*/
    width: 15px;
    background-image: url(../Images/on-off.gif);
    background-repeat: no-repeat;
    background-color: #9FC2F1;
}

#main
{
    left: 165px;
    top: 0;
    bottom: 0;
    right: 0;
}


/*------ for ie6---------------*/
html { *padding:0;}
#left { *height:100%; *float:left; *margin-right:-150px;}
#switchBar { *height:100%;*float:left; *margin-left:150px;*margin-right:-165px;}
#main { *height:100%; *margin-left:165px;}
#left,#switchBar, #main {*position:relative; *top:0; *right:0; *bottom:0; *left:0;}



使用如下代码在ie9下使用没有问题,但是在兼容模式下就不可以,该如何解决啊?!

var showLeftFlag=1;
function switchLeft() {
    if (window.showLeftFlag == 1) {
        window.showLeftFlag = 0;
        document.getElementById("left").style.display = "none";
        document.getElementById("switchBar").style.left = 0;
        document.getElementById("main").style.left = 15+"px";
    }
    else {
        window.showLeftFlag = 1;
        document.getElementById("left").style.display = "";
        document.getElementById("switchBar").style.left = 150+"px";
        document.getElementById("main").style.left = 165 + "px";
    }
}

------解决方案--------------------
IE9 是超级的麻烦
------解决方案--------------------
我测试了下代码,在我这边都能够兼容的,没有发现IE7,IE6有问题的情况
------解决方案--------------------
不知道你遇到的是什么问题