在做web开发的时候,最头疼的就是处理各种浏览器兼容。尤其是ie低版本的兼容。于是各种 css hack层出不穷。类似 _ * \9 \0一类的,功能是实现的,却让本来写得很整齐的 css 代码变得乱糟糟的。其实用ie的条件注释就可以很简单的解决处理这些问题。
示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <!DOCTYPE html> < html > <!--[if lt IE 7]><html class="ie6"><![endif]--> < head > < meta charset = "utf-8" > < title >css hack</ title > < style > .test {height: 40px; background: blue;} .ie6 .test {background: red;} </ style > </ head > < body > < p class = "test" ></ p > </ body > </ html > |