巧用css expression表达式解决IE6的下before

2021-04-09  本文已影响0人  NemoExpress

IE6支持在css样式中使用 expression表达式,所以,可以针对IE6,使用expression表达式,通过js动态给对应的元素添加新的div元素,具体操作如下。

.tabs {
    *zoom: expression(
        this.runtimeStyle.zoom="1",
        this.insertBefore(
            document.createElement("div"),
            this.childNodes[0]
        ).className="before",
        this.appendChild(
            document.createElement("div")
        ).className="after"
    );
}
...

.tabs::before, .tabs .before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 20px;
    background-color: #eee;
}
.tabs::after, .tabs .after {
    content: '';
    display:inline-block;
    width: 10px;
    height: 20px;
    background-color: #c0c;
}
上一篇 下一篇

猜你喜欢

热点阅读