IE6支持在css樣式中使用 expression表達式,所以,可以針對IE6,使用expression表達式,通過js動態(tài)給對應(yīng)的元素添加新的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;
}