¡¾×ܽ᡿ä¯ÀÀÆ÷CSS Hacks»ã×Ü
ä¯ÀÀÆ÷¼æÈÝ¿ÉÒÔ˵ÊÇÇ°¶Ë¿ª·¢ËùÒªÃæ¶ÔµÄµÚÒ»¸öÌôÕ½£¬Ä¿Ç°ÎҵĵçÄÔÉÏÒѾ°²×°ÁË6ÖÖä¯ÀÀÆ÷£¨»ùÓÚIEÄں˵IJ»Ë㣬ÈçMaxthonµÈ£©¡£
¡¡¡¡CSS hacksÀûÓÃä¯ÀÀÆ÷µÄ©¶´À´Òþ²ØÌض¨ä¯ÀÀÆ÷µÄCSS¹æÔò¡£ÊµÏÖä¯ÀÀÆ÷¼æÈÝÖ÷ÒªÓÐÁ½ÖÖ·½Ê½Ìõ¼þÑùʽ±íºÍCSS Hacks£¨Selector Hacks¡¢Attribute Hacks£©¡£¶Ô´Ë¸ù¾ÝһЩ×ÊÁÏ»ã×ÜÁËһЩCSS Hacks·½·¨¡£
1.Ìõ¼þÑùʽ±í
ÏñÕâÑùµÄ´úÂëÄãÓ¦¸Ã¼û¹ý:
<link rel="stylesheet" type="text/css" href="css/style.css" />
<!--[if IE]>
<link rel="stylesheet" type="text/css"href="css/ie.css" />
< ![endif]-->
PS£ºyahooµÄÄÚ²¿±àÂë×î¼Ñ×ö·¨²¢²»½¨ÒéʹÓÃÓÐÌõ¼þµÄÑùʽ±í¡£Ëü»áÔö¼Ó¶îÍâµÄƽ¾ù1»ò2¸öHTTPÏÂÔØÇëÇ󣨲ο¼ÕâÀ¡£
2. Ñ¡ÔñÆ÷Hacks£¨Selector Hacks£©
/* IE6 ¼°ÒÔÏÂ */
* html #uno { color: red }
/* IE7 */
*:first-child+html #dos { color: red }
/* IE7, FF, Saf, Opera */
html>body #tres { color: red }
/* IE8, FF, Saf, Opera (IE 6,7ÒÔÍâ) */
html>/**/body #cuatro { color: red }
/* Opera 9.27 ¼°ÒÔÏÂ, safari 2 */
html:first-child #cinco { color: red }
/* Safari 2-3 */
html[xmlns*=""] body:last-child #seis { color: red }
/* safari 3+, chrome 1+, opera9+, ff 3.5+ */
body:nth-of-type(1) #siete { color: red }
/* safari 3+, chrome 1+, opera9+, ff 3.5+ */
body:first-of-type #ocho { color: red }
/* saf3+, chrome1+ */
@media screen and (-webkit-min-device-pixel-ratio:0) {
#diez { color: red }
}
/* iPhone / mobile webkit */
@media screen and (max-device-width: 480px) {
#veintiseis { color: red }
}
/* Safari 2 - 3.1 */
html[xmlns*=""]:root #trece { color: red }
/* Safari 2 - 3.1, Opera 9.25 */
*|html[xmlns*=""] #catorce { color: red }
/* IE6-8ÒÔÍâ */
:root *> #quince { color: red }
/* IE7 */
*+html #dieciocho { color: red }
/* Firefox only. 1+ */
#veinticuatro, x:-moz-any-link { color: red }
/* Firefox 3.0+ */
#veinticinco, x:-moz-any-link, x:default { color: red }
PS£ºÑ¡ÔñÆ÷Hacks·½Ê½±È½Ï¶à£¬ µ«Ö»Òª´úÂëдµÃ¹»±ê×¼, ÆäʵҪ Hack µÄµØ·½²»»áºÜ¶àµÄ, ³ýÁËÓÐʱºòIEµ·ÂÒ£¬IE ÒÔÍâµÄä¯ÀÀÆ÷¼
Ïà¹ØÎĵµ£º
Ò»¡¢ÐǺÅ*
Ó¦¸ÃÊǸöͨÅä·û¡£±ÈÈç
<style type="text/css">
.roundBorder *
{
background: white;
display: block;
height: 1px;
overflow: hidden;
}
</style>
……
<b class="roundBorder">
<b class="round ......
ÔÚJSPÒ³ÃæÉϼÓÈë
<%String path = request.getContextPath();%>
<link href="<%=path%>/css/style.css" rel="stylesheet" type="text/css">
ÏÂÁз½Ê½Ã²ËƲ»ÐУº
<link href="../css/style.css" rel="stylesheet" type="text/css">
<link href="../../css/style.css" rel ......
Óà UL ÖÆ×÷²Ëµ¥ÏÖÔڷdz£Á÷ÐУ¬ÄÇÎÒÃÇÒ²´Õ´ÕÈÈÄÖ£¬µÚÒ»½²¾Í˵˵Óà UL ÖÆ×÷µ¼º½²Ëµ¥µÄ·½·¨£¬ÕâÒ»½²ÊÇÈëÃŰ棬ֻÊÇʵÏÖ»ù±¾¹¦ÄÜ£¬»¶Ó¸÷λ·¢²¼×Ô¼ºµÄʵÏÖ·½Ê½¡£
ÎÒÃÇÏȶ¨Ò»Ï HTML ´úÂ룺
<ul id="menu">
<li><a href="http://www.codebit.cn">CodeBit.cn</a></li>
<li><a href="h ......
¡¡¡¡CSSѧÆðÀ´²¢²»ÄÑ£¬µ«ÔÚ´óÐÍÏîÄ¿ÖУ¬¾Í±äµÃÄÑÒÔ¹ÜÀí£¬ÌرðÊDz»Í¬µÄÈËÔÚCSSÊéд·ç¸ñÉÏÉÔÓв»Í¬£¬ÍŶÓÉϾ͸ü¼ÓÄÑÒÔ¹µÍ¨£¬Îª´Ë×ܽáÁËһЩÈçºÎʵÏÖ¸ßЧÕû½àµÄCSS´úÂëÔÔò£º
1. ʹÓÃResetµ«²¢·ÇÈ«¾ÖReset
¡¡¡¡²»Í¬ä¯ÀÀÆ÷ÔªËصÄĬÈÏÊôÐÔÓÐËù²»Í¬£¬Ê¹ÓÃReset¿ÉÖØÖÃä¯ÀÀÆ÷ÔªËصÄһЩĬÈÏÊôÐÔ£¬ÒÔ´ïµ½ä¯ÀÀÆ÷µÄ¼æÈÝ¡£µ«ÐèÒª×¢Ò ......
¡¡¡¡½üÄêÀ´£¬CSS²»Í¸Ã÷ËãµÃÉÏÊÇÒ»ÖÖÏ൱Á÷Ðеļ¼Êõ£¬µ«ÔÚ¿çä¯ÀÀÆ÷Ö§³ÖÉÏ£¬¶ÔÓÚ¿ª·¢ÕßÀ´Ëµ£¬¿ÉÒÔ˵ÊÇÒ»¼þÁîÈËÍ·ÌÛµÄÊÂÇ顣Ŀǰ»¹Ã»ÓÐÒ»¸öͨÓ÷½·¨£¬ÒÔÈ·±£Í¸Ã÷¶ÈÉèÖÿÉÒÔÔÚĿǰʹÓõÄËùÓÐä¯ÀÀÆ÷ÉÏÓÐЧ¡£
¡¡¡¡Õâƪ»ã×ÜÖ÷ÒªÊÇÌṩһЩCSS²»Í¸Ã÷µÄÏêϸ½éÉÜ£¬´úÂëʾÀýºÍ½âÊÍ£¬ÒÔʵÏÖÕâÏîÓÐÓõÄCSS¼¼ÊõÔÚÄúµÄÏîÄ¿ÖмæÈÝËùÓÐä¯À ......