csshack用法.docx
- 文档编号:14822467
- 上传时间:2023-06-27
- 格式:DOCX
- 页数:19
- 大小:21.01KB
csshack用法.docx
《csshack用法.docx》由会员分享,可在线阅读,更多相关《csshack用法.docx(19页珍藏版)》请在冰点文库上搜索。
csshack用法
1ifhack
DOCTYPEhtml>
--
描述:
-->
--[iflteIE8]>
[endif]-->
body{
background-color:
deepskyblue;
}
<!--[if<keywords>?
IE<version>?
]>
HTML代码块
<!
[endif]-->
if条件共包含6种选择方式:
是否、大于、大于或等于、小于、小于或等于、非指定版本
- 是否:
- 指定是否IE或IE某个版本。
关键字:
空 - 大于:
- 选择大于指定版本的IE版本。
关键字:
gt(greaterthan) - 大于或等于:
- 选择大于或等于指定版本的IE版本。
关键字:
gte(greaterthanorequal) - 小于:
- 选择小于指定版本的IE版本。
关键字:
lt(lessthan) - 小于或等于:
- 选择小于或等于指定版本的IE版本。
关键字:
lte(lessthanorequal) - 非指定版本:
- 选择除指定版本外的所有IE版本。
关键字:
!
目前的常用IE版本为6.0及以上,推荐酌情忽略低版本,把精力花在为使用高级浏览器的用户提供更好的体验上
用于选择IE浏览器及IE的不同版本
- if条件Hack是HTML级别的(包含但不仅是CSS的Hack,可以选择任何HTML代码块)
- if条件6种选择方式的使用示例(下述代码中被条件注释包含的HTML代码块也可以是link标记):
<!
--[ifIE]>
<p>你在非IE中将看不到我的身影</p>
<!
[endif]-->
<!
--[ifIE]>
<style>
.test{color:
red;}
</style>
<!
[endif]-->
<!
--[ifgtIE6]>
<style>
.test{color:
red;}
</style>
<!
[endif]-->
<!
--[ifgteIE6]>
<style>
.test{color:
red;}
</style>
<!
[endif]-->
<!
--[ifltIE7]>
<style>
.test{color:
red;}
</style>
<!
[endif]-->
<!
--[iflteIE7]>
<style>
.test{color:
red;}
</style>
<!
[endif]-->
<!
--[if!
IE7]>
<style>
.test{color:
red;}
</style>
<!
[endif]-->