å¨ç½ç«è®¾è®¡çæ¶åï¼åºè¯¥æ³¨æcssæ ·å¼å
¼å®¹ä¸åæµè§å¨é®é¢ï¼ç¹å«æ¯å¯¹å®å
¨ä½¿ç¨DIV CSS设计çç½ï¼å°±åºè¯¥æ´æ³¨æIE6 IE7 FF对CSSæ ·å¼çå
¼å®¹ï¼
æææµè§å¨ éç¨ height: 100px; IE6 ä¸ç¨ _height: 100px; IE6 ä¸ç¨ *height: 100px; IE7 ä¸ç¨ *+height: 100px; IE7ãFF å
±ç¨ height: 100px !important;
ä¸ãCSS HACK
1, !important
éçIE7对!importantçæ¯æ, !important æ¹æ³ç°å¨åªé对IE6çHACK.
以ä¸ä¸ºå¼ç¨çå
容ï¼
2, IE6/IE7对FireFox
以ä¸ä¸ºå¼ç¨çå
容ï¼*+html ä¸ *html æ¯IEç¹æçæ ç¾, firefox æä¸æ¯æ.è*+html å为 IE7ç¹ææ ç¾.
注æ:*+html 对IE7çHACK å¿
é¡»ä¿è¯HTML顶é¨æå¦ä¸å£°æï¼
äºãä¸è½ float éå
å
³äº clear float çåçå¯åè§ [How To Clear Floats Without Structural Markup]å°ä»¥ä¸ä»£ç å å
¥Global CSS ä¸,ç»éè¦éåçdivå ä¸ class=âclearfixâ å³å¯
以ä¸ä¸ºå¼ç¨çå
容ï¼
ä¸ãå
¶ä»å
¼å®¹æå·§
1, FFä¸ç» div 设置 padding åä¼å¯¼è´ width å height å¢å , ä½IEä¸ä¼.(å¯ç¨!important解å³) å¦width:115px !important;width:120px;padding:5px;
å¿
须注æçæ¯ï¼ !important; ä¸å®è¦å¨åé¢ã 2, å±
ä¸é®é¢.1).åç´å±
ä¸.å° line-height 设置为 å½å div ç¸åçé«åº¦, åéè¿ vertical-align: middle.( 注æå
容ä¸è¦æ¢è¡.)2).æ°´å¹³å±
ä¸. margin: 0 auto;(å½ç¶ä¸æ¯ä¸è½)3, è¥éç» a æ ç¾å
å
容å ä¸ æ ·å¼, éè¦è®¾ç½® display: block;(常è§äºå¯¼èªæ ç¾)4, FF å IE 对 BOX ç解çå·®å¼å¯¼è´ç¸å·® 2px çè¿æ设为 floatçdivå¨ieä¸ marginå åçé®é¢.5, ul æ ç¾å¨ FF ä¸é¢é»è®¤æ list-style å padding . æ好äºå
声æ, 以é¿å
ä¸å¿
è¦ç麻ç¦. (常è§äºå¯¼èªæ ç¾åå
容å表)6, ä½ä¸ºå¤é¨ wrapper ç div ä¸è¦å®æ»é«åº¦, æ好è¿å ä¸ overflow: hidden.以达å°é«åº¦èªéåº.7, å
³äºæå½¢å
æ . cursor: pointer. èhand åªéç¨äº IE.
å
¼å®¹ä»£ç :å
¼å®¹ææ¨èç模å¼ã .submitbutton { float:left; width: 40px; height: 57px; margin-top: 24px; margin-right: 12px; } *html .submitbutton { margin-top: 21px; } *+html .submitbutton { margin-top: 21px; } ä»ä¹æ¯æµè§å¨å
¼å®¹ï¼å½ä½¿ç¨ä¸åçæµè§å¨ï¼Firefox IE7 IE6ï¼è®¿é®åä¸ä¸ªç½ç«ï¼æè
页é¢çæ¶åï¼ä¼åºç°ä¸äºä¸å
¼å®¹çé®é¢ï¼æçæ¾ç¤ºåºæ¥æ£å¸¸ï¼æçæ¾ç¤ºåºæ¥ä¸æ£å¸¸ï¼å¨ç¼åCSSçæ¶åä¼å¾æ¼ç«ï¼åä¿®å¤äºè¿ä¸ªæµè§å¨çé®é¢ï¼ç»æå¦å¤ä¸ä¸ªæµè§å¨å´åºäºæ°é®é¢ãèå
¼å®¹å°±æ¯ä¸ç§åæ³ï¼è½è®©å¨ä¸ä¸ªCSSéé¢ç¬ç«çåæ¯æä¸åæµè§å¨çæ ·å¼ã
æè¿å¾®è½¯åå¸çIE7æµè§å¨çå
¼å®¹æ§ç¡®å®ç»ä¸äºç½é¡µå¶ä½äººåæ·»å äºä¸ä¸ªæ²éçè´æ
ï¼è½ç¶IE7å·²ç»èµ°åæ ååï¼ä½è¿æ¯æ许å¤åFFä¸åçå°æ¹ï¼æ以éè¦ç¨å°IE7çå
¼å®¹ãæä¸ç¹é»è¾ææ³ç人é½ä¼ç¥éå¯ä»¥ç¨IEåFFçå
¼å®¹ç»åèµ·æ¥ä½¿ç¨ï¼ä¸é¢ä»ç»ä¸ä¸ªå
¼å®¹ï¼ä¾å¦ï¼ç¨åºä»£ç 第ä¸ä¸ªå
¼å®¹ï¼IE FF æææµè§å¨ å
¬ç¨ï¼å
¶å®ä¹ä¸ç®æ¯å
¼å®¹ï¼ height:100px; 第äºä¸ªå
¼å®¹ IE6ä¸ç¨ _height:100px; 第ä¸ä¸ªå
¼å®¹ IE6 IE7å
¬ç¨ *height:100px; ä»ç»å®äºè¿ä¸ä¸ªå
¼å®¹äºï¼ä¸é¢åæ¥ççå¦ä½å¨ä¸ä¸ªæ ·å¼éåå«ç»ä¸ä¸ªå±æ§å®ä¹IE6 IE7 FFä¸ç¨çå
¼å®¹ï¼çä¸é¢ç代ç ï¼é¡ºåºä¸è½éï¼ ç¨åºä»£ç height:100px; *height:120px; _height:150px; ä¸é¢ç®å解éä¸ä¸åæµè§å¨ææ ·ç解è¿ä¸ä¸ªå±æ§ï¼ å¨FFä¸ï¼ç¬¬2ã3个å±æ§FFä¸è®¤è¯ï¼æ以å®è¯»çæ¯ height:100px; å¨IE7ä¸ï¼ç¬¬ä¸ä¸ªå±æ§IE7ä¸è®¤è¯ï¼æ以å®è¯»ç¬¬1ã2个å±æ§ï¼åå 为第äºä¸ªå±æ§è¦çäºç¬¬ä¸ä¸ªå±æ§ï¼æ以IE7æç»è¯»åºçæ¯ç¬¬2个å±æ§ *height:120px; å¨IE6ä¸ï¼ä¸ä¸ªå±æ§IE6é½è®¤è¯ï¼æ以ä¸ä¸ªå±æ§é½å¯ä»¥è¯»åï¼åå 为第ä¸ä¸ªå±æ§è¦çæå2个å±æ§ï¼æ以IE6æç»è¯»åçæ¯ç¬¬ä¸ä¸ªå±æ§ã
1 é对firefox ie6 ie7çcssæ ·å¼ç°å¨å¤§é¨åé½æ¯ç¨!importantæ¥hackï¼å¯¹äºie6åfirefoxæµè¯å¯ä»¥æ£å¸¸æ¾ç¤ºï¼ä½æ¯ie7对!importantå¯ä»¥æ£ç¡®è§£éï¼ä¼å¯¼è´é¡µé¢æ²¡æè¦æ±æ¾ç¤ºï¼æ¾å°ä¸ä¸ªé对IE7ä¸éçhackæ¹å¼å°±æ¯ä½¿ç¨â*+htmlâï¼ç°å¨ç¨IE7æµè§ä¸ä¸ï¼åºè¯¥æ²¡æé®é¢äºãç°å¨åä¸ä¸ªCSSå¯ä»¥è¿æ ·ï¼
以ä¸ä¸ºå¼ç¨çå
容ï¼#1 { color: #333; }* html #1 { color: #666; }*+html #1 { color: #999; }
é£ä¹å¨firefoxä¸åä½é¢è²æ¾ç¤ºä¸º#333ï¼IE6ä¸åä½é¢è²æ¾ç¤ºä¸º#666ï¼IE7ä¸åä½é¢è²æ¾ç¤ºä¸º#999ã
2 csså¸å±ä¸çå±
ä¸é®é¢ä¸»è¦çæ ·å¼å®ä¹å¦ä¸ï¼
body {TEXT-ALIGN: center;}#center { MARGIN-RIGHT: auto; MARGIN-LEFT: auto; }说æï¼é¦å
å¨ç¶çº§å
ç´ å®ä¹TEXT-ALIGN: center;è¿ä¸ªçææå°±æ¯å¨ç¶çº§å
ç´ å
çå
容å±
ä¸ï¼å¯¹äºIEè¿æ ·è®¾å®å°±å·²ç»å¯ä»¥äºãä½å¨mozillaä¸ä¸è½å±
ä¸ã解å³åæ³å°±æ¯å¨åå
ç´ å®ä¹æ¶å设å®æ¶åå ä¸âMARGIN-RIGHT: auto;MARGIN-LEFT: auto; âéè¦è¯´æçæ¯ï¼å¦æä½ æ³ç¨è¿ä¸ªæ¹æ³ä½¿æ´ä¸ªé¡µé¢è¦å±
ä¸ï¼å»ºè®®ä¸è¦å¥å¨ä¸ä¸ªDIVéï¼ä½ å¯ä»¥ä¾æ¬¡æåºå¤ä¸ªdivï¼åªè¦å¨æ¯ä¸ªæåºçdivéå®ä¹MARGIN-RIGHT: auto;MARGIN-LEFT: auto; å°±å¯ä»¥äºã
3 ç模åä¸å解é
#box{ width:600px; //for ie6.0- w\idth:500px; //for ff+ie6.0}#box{ width:600px!important //for ff width:600px; //for ff+ie6.0 width :500px; //for ie6.0-}
4 æµ®å¨ie产ççååè·ç¦»
#box{ float:left; width:100px; margin:0 0 0 100px; //è¿ç§æ
åµä¹ä¸IEä¼äº§ç200pxçè·ç¦» display:inline; //使浮å¨å¿½ç¥}è¿éç»è¯´ä¸ä¸block,inline两个å
ç´ ,Blockå
ç´ çç¹ç¹æ¯:æ»æ¯å¨æ°è¡ä¸å¼å§,é«åº¦,宽度,è¡é«,è¾¹è·é½å¯ä»¥æ§å¶(åå
ç´ );Inlineå
ç´ çç¹ç¹æ¯:åå
¶ä»å
ç´ å¨åä¸è¡ä¸,â¦ä¸å¯æ§å¶(å
åµå
ç´ );
#box{ display:block; //å¯ä»¥ä¸ºå
åµå
ç´ æ¨¡æ为åå
ç´ display:inline; //å®ç°åä¸è¡æåççææ diplay:table;
IEä¸è®¤å¾min-è¿ä¸ªå®ä¹ï¼ä½å®é
ä¸å®ææ£å¸¸çwidthåheightå½ä½æminçæ
åµæ¥ä½¿ãè¿æ ·é®é¢å°±å¤§äºï¼å¦æåªç¨å®½åº¦åé«åº¦ï¼æ£å¸¸çæµè§å¨éè¿ä¸¤ä¸ªå¼å°±ä¸ä¼åï¼å¦æåªç¨min-widthåmin-heightçè¯ï¼IEä¸é¢æ ¹æ¬çäºæ²¡æ设置宽度åé«åº¦ãæ¯å¦è¦è®¾ç½®èæ¯å¾çï¼è¿ä¸ªå®½åº¦æ¯æ¯è¾éè¦çãè¦è§£å³è¿ä¸ªé®é¢ï¼å¯ä»¥è¿æ ·ï¼#box{ width: 80px; height: 35px;}html>body #box{ width: auto; height: auto; min-width: 80px; min-height: 35px;}
6 页é¢çæå°å®½åº¦
min-widthæ¯ä¸ªé常æ¹ä¾¿çCSSå½ä»¤ï¼å®å¯ä»¥æå®å
ç´ æå°ä¹ä¸è½å°äºæ个宽度ï¼è¿æ ·å°±è½ä¿è¯æçä¸ç´æ£ç¡®ãä½IEä¸è®¤å¾è¿ä¸ªï¼èå®å®é
ä¸æwidthå½åæå°å®½åº¦æ¥ä½¿ã为äºè®©è¿ä¸å½ä»¤å¨IEä¸ä¹è½ç¨ï¼å¯ä»¥æä¸ä¸ª
æ¾å°æ ç¾ä¸ï¼ç¶å为divæå®ä¸ä¸ªç±»ï¼ç¶åCSSè¿æ ·è®¾è®¡ï¼#container{ min-width: 600px; width:expression_r(document.body.clientWidth < 600? â600pxâ: âautoâ );}第ä¸ä¸ªmin-widthæ¯æ£å¸¸çï¼ä½ç¬¬2è¡çwidth使ç¨äºJavascriptï¼è¿åªæIEæ认å¾ï¼è¿ä¹ä¼è®©ä½ çHTMLææ¡£ä¸å¤ªæ£è§ãå®å®é
ä¸éè¿Javascriptçå¤ææ¥å®ç°æå°å®½åº¦ã
7 æ¸
é¤æµ®å¨
.hackbox{ display:table; //å°å¯¹è±¡ä½ä¸ºåå
ç´ çº§çè¡¨æ ¼æ¾ç¤º}æè
.hackbox{ clear:both;}æè
å å
¥:afterï¼ä¼ªå¯¹è±¡ï¼,设置å¨å¯¹è±¡ååççå
容ï¼é常åcontenté
å使ç¨ï¼IEä¸æ¯ææ¤ä¼ªå¯¹è±¡ï¼éIe æµè§å¨æ¯æï¼æ 以并ä¸å½±åå°IE/WINæµè§å¨ãè¿ç§çæ麻ç¦çâ¦â¦#box:after{ content: â.â; display: block; height: 0; clear: both; visibility: hidden;}
8 DIVæµ®å¨IEææ¬äº§ç3è±¡ç´ çbug
左边对象浮å¨ï¼å³è¾¹éç¨å¤è¡¥ä¸ç左边è·æ¥å®ä½ï¼å³è¾¹å¯¹è±¡å
çææ¬ä¼ç¦»å·¦è¾¹æ3pxçé´è·.
#box{ float:left; width:800px;}#left{ float:left; width:50%;}#right{ width:50%;}*html #left{ margin-right:-3px; //è¿å¥æ¯å
³é®}HTML代ç
9 å±æ§éæ©å¨(è¿ä¸ªä¸è½ç®æ¯å
¼å®¹,æ¯éècssçä¸ä¸ªbug)
p[id]{}div[id]{}è¿ä¸ªå¯¹äºIE6.0åIE6.0以ä¸ççæ¬é½éè,FFåOPeraä½ç¨å±æ§éæ©å¨ååéæ©å¨è¿æ¯æåºå«ç,åéæ©å¨çèå´ä»å½¢å¼æ¥è¯´ç¼©å°äº,å±æ§éæ©å¨çèå´æ¯è¾å¤§,å¦p[id]ä¸,ææpæ ç¾ä¸æidçé½æ¯åæ ·å¼ç.
10 IEæè¿·èçé®é¢
å½divåºç¨å¤æçæ¶åæ¯ä¸ªæ ä¸åæä¸äºé¾æ¥ï¼DIVçè¿ä¸ªæ¶å容æåçæè¿·èçé®é¢ãæäºå
容æ¾ç¤ºä¸åºæ¥ï¼å½é¼ æ éæ©è¿ä¸ªåºåæ¯åç°å
容确å®å¨é¡µé¢ã解å³åæ³ï¼å¯¹#layout使ç¨line-heightå±æ§ æè
ç»#layout使ç¨åºå®é«å宽ã页é¢ç»æå°½éç®åã
11 é«åº¦ä¸éåº é«åº¦ä¸éåºæ¯å½å
å±å¯¹è±¡çé«åº¦åçååæ¶å¤å±é«åº¦ä¸è½èªå¨è¿è¡è°èï¼ç¹å«æ¯å½å
å±å¯¹è±¡ä½¿ç¨ margin æpaddign æ¶ãä¾ï¼
p对象ä¸çå
容
CSSï¼ #box {background-color:#eee; } #box p {margin-top: 20px;margin-bottom: 20px; text-align:center; } 解å³æ¹æ³ï¼å¨P对象ä¸ä¸åå 2个空çdiv对象CSS代ç ï¼.1{height:0px;overflow:hidden;}æè
为DIVå ä¸borderå±æ§ã å±è½IEæµè§å¨ï¼ä¹å°±æ¯IEä¸ä¸æ¾ç¤ºï¼ *:lang(zh) select {font:12px !important;} select:empty {font:12px !important;} è¿éselectæ¯éæ©ç¬¦ï¼æ ¹æ®æ
åµæ´æ¢ã第äºå¥æ¯MACä¸safariæµè§å¨ç¬æçã ä»
IE7è¯å« *+html {â¦} å½é¢ä¸´éè¦åªé对IE7åæ ·å¼çæ¶åå°±å¯ä»¥éç¨è¿ä¸ªå
¼å®¹ã IE6åIE6以ä¸è¯å« * html {â¦} è¿ä¸ªå°æ¹è¦ç¹å«æ³¨æå¾å¤å°ä¸»é½åäºæ¯IE6çå
¼å®¹å
¶å®IE5.xåæ ·å¯ä»¥è¯å«è¿ä¸ªå
¼å®¹ãå
¶å®æµè§å¨ä¸è¯å«ã html >body select {â¦â¦} è¿å¥ä¸ä¸ä¸å¥çä½ç¨ç¸åã ä»
IE6ä¸è¯å« select { display :none;} è¿é主è¦æ¯éè¿CSS注éåå¼ä¸ä¸ªå±æ§ä¸å¼ï¼æµéå¨åå·åã ä»
IE6ä¸IE5ä¸è¯å« select { display :none;} è¿éä¸ä¸é¢ä¸å¥ä¸åçæ¯å¨éæ©ç¬¦ä¸è±æ¬å·ä¹é´å¤äºä¸ä¸ªCSS注éã ä»
IE5ä¸è¯å« select { display:none;} è¿ä¸å¥æ¯å¨ä¸ä¸å¥ä¸å»æäºå±æ§åºç注éãåªæIE5ä¸è¯å« ç模å解å³æ¹æ³ selct {width:IE5.x宽度; voice-family :""}""; voice-family:inherit; width:æ£ç¡®å®½åº¦;} ç模åçæ¸
é¤æ¹æ³ä¸æ¯éè¿!importantæ¥å¤ççãè¿ç¹è¦æç¡®ã æ¸
é¤æµ®å¨ select:after {content:"."; display:block; height:0; clear:both; visibility:hidden;} å¨Firefoxä¸ï¼å½å级é½ä¸ºæµ®å¨æ¶ï¼é£ä¹ç¶çº§çé«åº¦å°±æ æ³å®å
¨çå
ä½æ´ä¸ªå级ï¼é£ä¹è¿æ¶ç¨è¿ä¸ªæ¸
é¤æµ®å¨çå
¼å®¹æ¥å¯¹ç¶çº§åä¸æ¬¡å®ä¹ï¼é£ä¹å°±å¯ä»¥è§£å³è¿ä¸ªé®é¢ ã æªåçç¥å· select { -o-text-overflow:ellipsis; text-overflow:ellipsis; white-space:nowrapoverflow:hidden; } è¿ä¸ªæ¯å¨è¶åºé¿åº¦åä¼èªè¡çæªæå¤åºé¨åçæåï¼å¹¶ä»¥çç¥å·ç»å°¾ï¼å¾å¥½çä¸ä¸ªææ¯ãåªæ¯ç®åFirefox并ä¸æ¯æã åªæOperaè¯å« @media all and (min-width: 0px){ select {â¦â¦} } é对Operaæµè§å¨ååç¬ç设å®ã 以ä¸é½æ¯åCSSä¸çä¸äºå
¼å®¹ï¼å»ºè®®éµå¾ªæ£ç¡®çæ ç¾åµå¥(div ul li åµå¥ç»æå
³ç³»)ï¼è¿æ ·å¯ä»¥åå°ä½ 使ç¨å
¼å®¹çé¢çï¼ä¸è¦è¿å
¥ç解误åºï¼å¹¶ä¸æ¯ä¸ä¸ªé¡µé¢å°±éè¦å¾å¤çå
¼å®¹æ¥ä¿æå¤æµè§å¨å
¼å®¹)ï¼å¾å¤æ
åµä¸ä¹è®¸ä¸ä¸ªå
¼å®¹é½ä¸ç¨ä¹å¯ä»¥è®©æµè§å¨å·¥ä½å¾é常好ï¼è¿äºé½æ¯ç¨æ¥è§£å³å±é¨çå
¼å®¹æ§é®é¢ï¼å¦æå¸ææå
¼å®¹æ§çå
容ä¹å离åºæ¥ï¼ä¸å¦¨è¯ä¸ä¸ä¸é¢çå ç§è¿æ»¤å¨ãè¿äºè¿æ»¤å¨æçæ¯åå¨CSSä¸éè¿è¿æ»¤å¨å¯¼å
¥ç¹å«çæ ·å¼ï¼ä¹æçæ¯åå¨HTMLä¸çéè¿æ¡ä»¶æ¥é¾æ¥ææ¯å¯¼å
¥éè¦çè¡¥ä¸æ ·å¼ã IE5.xçè¿æ»¤å¨ï¼åªæIE5.xå¯è§ @media tty { i{content:"";}} @import âie5win.cssâ; IE5/MACçè¿æ»¤å¨ï¼ä¸è¬ç¨ä¸ç ä¸é¢æ¯IEçæ¡ä»¶æ³¨éï¼ä¸ªäººè§å¾ç¨æ¡ä»¶æ³¨éè°ç¨ç¸åº å
¼å®¹æ¯æ¯è¾å®ç¾çå¤æµè§å¨å
¼å®¹ç解å³åæ³ãæéè¦å
¼å®¹çå°æ¹åç¬æ¾å°ä¸ä¸ªæ件éé¢ï¼å½æµè§å¨çæ¬ç¬¦åçæ¶åå°±å¯ä»¥è°ç¨é£ä¸ªè¢«å
¼å®¹çæ ·å¼ï¼è¿æ ·ä¸ä»
使ç¨èµ·æ¥é常æ¹ä¾¿ï¼èä¸å¯¹äºå¶ä½è¿ä¸ªCSSæ¬èº«æ¥è®²ï¼å¯ä»¥æ´ä¸¥æ ¼çè§å¯å°æ¯å¦æå¿
è¦ä½¿ç¨å
¼å®¹ï¼å¾å¤æ
åµä¸ï¼å½ææ¬äººåCSSå¦ææå
¨é¨ä»£ç å
æ¬å
¼å®¹é½åå°ä¸ä¸ªCSSæ件çæ¶åçæ¶åä¼å¾éæï¼æ³æä¹å
¼å®¹å°±æä¹å
¼å®¹ï¼èä½ ç¬ç«åºæ¥åçæ¶åï¼ä½ å°±ä¼ä¸èªè§çèèæ¯å¦æå¿
è¦å
¼å®¹ï¼æ¯å
å
¼å®¹ CSSï¼è¿æ¯å
æ主CSSéé¢çä¸è¥¿è°æ´å°å°½å¯è½çä¸éè¦å
¼å®¹ï¼å½ä½ ä»
ç¨å¾å°çå
¼å®¹å°±è®©å¾å¤æµè§å¨å¾ä¹å¾å¬è¯çæ¶åï¼ä½ æ¯ä¸æ¯å¾ææå°±æå¢ï¼ä½ ç¥éæä¹éæ©äºå§ï½ï½åµåµ IEçifæ¡ä»¶å
¼å®¹ èªå·±å¯ä»¥çµæ´»ä½¿ç¨åçè¿ç¯IEæ¡ä»¶æ³¨é Only IE ææçIEå¯è¯å« åªæIE5.0å¯ä»¥è¯å« Only IE 5.0+ IE5.0å
æ¢IE5.5é½å¯ä»¥è¯å« ä»
IE6å¯è¯å« Only IE 7/- IE6以åIE6以ä¸çIE5.xé½å¯è¯å« Only IE 7/- ä»
IE7å¯è¯å« Css å½ä¸æ许å¤çä¸è¥¿ä¸æç
§æäºè§å¾æ¥çè¯ï¼ä¼è®©ä½ å¾å¿ç¦ï¼è½ç¶ä½ å¯ä»¥éè¿å¾å¤çå
¼å®¹ï¼å¾å¤ç!important æ¥æ§å¶å®ï¼ä½æ¯ä½ ä¼åç°é¿æ¤ä»¥å¾ä½ ä¼å¾ä¸çå¿ï¼çç许å¤ä¼ç§çç½ç«ï¼ä»ä»¬çCSS让IE6,Ie7,Firefox,çè³Safari,Operaè¿è¡èµ·æ¥å®ç¾æ 缺æ¯ä¸æ¯å¾ç¾¡æ
ï¼èä»ä»¬çä¼¼å¤æç模çä¸é¢ä½¿ç¨çå
¼å®¹ å°å¾å¯æãå
¶å®ä½ è¦ç¥éIE å Firefox 并ä¸ä¸æ¯é£ä¹çä¸åè°ï¼æ们æ¾å°ä¸å®çæ¹æ³ï¼æ¯å®å
¨å¯ä»¥è®©ä»ä»¬åè°å
±å¤çãä¸è¦ä½ 认为åç°äºå
¼å®¹çåæ³ï¼ä½ å°±ææ¡äºä¸åï¼æ们并ä¸æ¯å
¼å®¹ç奴é¶ã div ul li çåµå¥é¡ºåº ä»å¤©åªè®²ä¸ä¸ªè§åãå°±æ¯ä¸è§å
³ç³»ãå°±æ¯å¨æå¤é¢ï¼éé¢æ¯ï¼èä¸ç¨çæ¶åï¼ä½ ä¼åç°ä½ çé´éååé¾æ§å¶ï¼ä¸è¬æ
åµä¸ï¼IE6åIE7ä¼å空å¤ä¸äºé´è·ãä½å¾å¤æ
åµä½ æ¥å°ä¸ä¸è¡ï¼é´é就没äºï¼ä½æ¯åé¢çå
容å空äºå¾å¤§ä¸åï¼åºç°è¿ç§æ
åµè½ç¶ä½ å¯ä»¥æ¹åIEçMarginï¼ç¶åè°æ´Firefoxä¸é¢çPaddingï¼ä»¥ä¾¿ä½¿å¾ä¸¤è
æ¾ç¤ºèµ·æ¥å¾ææå¾ç¸ä¼¼ï¼ä½æ¯ä½ å¾CSSå°åå¾èé¿æ æ¯ï¼ä½ ä¸å¾ä¸å¤èèæ´å¤å¯è½åºç°è¿ç§é®é¢è¡¥ææªæ½ï¼è½ç¶ä½ ç¥éåç¯ä¸å¾æ¥å
¼å®¹å®ä»¬ï¼ä½æ¯ä½ ä¼ç¦å¾è¦å½ã
å
·ä½åµå¥åæ³
éµå¾ªä¸é¢å¾åµå¥æ¹å¼ï¼ç¶åå¨CSS éé¢åè¯ ul {Margin:0px;Padding:0px;list-style:none;}ï¼å
¶ä¸list-style:noneæ¯ä¸è®©
æ è®°çæåæ¹æ¾ç¤ºåç¹æè
æ°åçç®å½ç±»åçæ è®°ï¼å 为IEåFirefoxæ¾ç¤ºåºæ¥é»è®¤æææäºä¸ä¸æ ·ãå æ¤è¿æ ·ä¸éè¦åä»»ä½æèï¼ä½ çIE6ãåIE7ãFirefoxæ¾ç¤ºåºæ¥çä¸è¥¿(å¤è·ï¼é´è·ï¼é«åº¦ï¼å®½åº¦)å°±å ä¹æ²¡ä»ä¹åºå«äºï¼ä¹è®¸ç»å¿çä½ ä¼å¨æä¸ä¸ªæ¶å»åç°ï¼ä¸¤ä¸ªè±¡ç´ çå·®å«ï¼ä½é£å·²ç»å¾å®ç¾äºï¼ä¸éè¦ä½ éè¿è°æ´å¤§ççCSSæ¥æ§å¶å®ä»¬çæ¾ç¤ºäºï¼ä½ æ¿æï¼ä½ å¯ä»¥ä»
ä»
å
¼å®¹ä¸ä¸¤ä¸ªå°æ¹ï¼èä¸é常è¿ç§å
¼å®¹å¯ä»¥éåºåç§å°æ¹ï¼ä¸éè¦ä½ éå¤å¨ä¸åçå°æ¹è°è¯ä¸åçå
¼å®¹æ¹å¼âåè½»ä½ çç¦ãä½ å¯ä»¥ul.class1, ul.class2, ul.class3 {xxx:xxxx}çæ¹å¼æ¹ä¾¿çæ´çåºä½ è¦å
¼å®¹çå°æ¹ï¼èç»ä¸å
¼å®¹ãå°è¯ä¸ä¸å§ï¼åä¹ä¸è¦ä¹±åµå¥äºï¼è½ç¶å¨Div+CSSçæ¹å¼ä¸ä½ å ä¹å¯ä»¥æ³æä¹åµå¥å°±æä¹åµå¥ï¼ä½æ¯æç
§ä¸é¢çè§å¾ä½ å°è½»æ¾å¾å¤ï¼ä»èäºåååï¼
å
ãCSSå
¼å®¹è¦ç¹åæIE vs FF
CSS å
¼å®¹è¦ç¹ï¼
DOCTYPE å½±å CSS å¤ç
FF: div 设置 margin-left, margin-right 为 auto æ¶å·²ç»å±
ä¸, IE ä¸è¡
FF: body 设置 text-align æ¶, div éè¦è®¾ç½® margin: auto(主è¦æ¯ margin-left,margin-right) æ¹å¯å±
ä¸
FF: 设置 padding å, div ä¼å¢å height å width, ä½ IE ä¸ä¼, æ
éè¦ç¨ !important å¤è®¾ä¸ä¸ª height å width
FF: æ¯æ !important, IE å忽ç¥, å¯ç¨ !important 为 FF ç¹å«è®¾ç½®æ ·å¼
div çåç´å±
ä¸é®é¢: vertical-align:middle; å°è¡è·å¢å å°åæ´ä¸ªDIVä¸æ ·é« line-height:200px; ç¶åæå
¥æåï¼å°±åç´å±
ä¸äºã缺ç¹æ¯è¦æ§å¶å
容ä¸è¦æ¢è¡
cursor: pointer å¯ä»¥åæ¶å¨ IE FF ä¸æ¾ç¤ºæ¸¸æ ææç¶ï¼ hand ä»
IE å¯ä»¥
FF: é¾æ¥å è¾¹æ¡åèæ¯è²ï¼é设置 display: block, åæ¶è®¾ç½® float: left ä¿è¯ä¸æ¢è¡ãåç
§ menubar, ç» a å menubar 设置é«åº¦æ¯ä¸ºäºé¿å
åºè¾¹æ¾ç¤ºéä½, è¥ä¸è®¾ height, å¯ä»¥å¨ menubar ä¸æå
¥ä¸ä¸ªç©ºæ ¼XHTML+CSSå
¼å®¹æ§è§£å³æ¹æ¡å°é
使ç¨XHTMLï¼CSSææ¶å¥½å¤ä¸å°ï¼ä½ä¹ç¡®å®åå¨ä¸äºé®é¢ï¼ä¸è®ºæ¯å 为使ç¨ä¸çç»è¿æ¯æè·¯ä¸æ¸
æ°ï¼æå°±å
æä¸äºæéå°çé®é¢åå¨ä¸é¢ï¼çç大家åå¤æ¾^^
1ãå¨mozilla firefoxåIEä¸çBOX模å解éä¸ä¸è´å¯¼è´ç¸å·®2px解å³æ¹æ³ï¼
div{margin:30px!important;margin:28px;}
注æè¿ä¸¤ä¸ªmarginç顺åºä¸å®ä¸è½ååï¼æ®é¿æ·ç说æ³!importantè¿ä¸ªå±æ§IEä¸è½è¯å«ï¼ä½å«çæµè§å¨å¯ä»¥è¯å«ãæ以å¨IEä¸å
¶å®è§£éæè¿æ ·ï¼
div{maring:30px;margin:28px}
éå¤å®ä¹çè¯æç
§æåä¸ä¸ªæ¥æ§è¡ï¼æ以ä¸å¯ä»¥åªåmargin:XXpx!important;
2ãIE5 åIE6çBOX解éä¸ä¸è´IE5ä¸div{width:300px;margin:0 10px 0 10px;}divç宽度ä¼è¢«è§£é为300px-10px(å³å¡«å
)-10px(左填å
)æç»divç宽度为280pxï¼èå¨IE6åå
¶ä»æµè§å¨ä¸å®½åº¦åæ¯ä»¥300px+10px(å³å¡«å
)+10px(左填å
)=320pxæ¥è®¡ç®çãè¿æ¶å¯ä»¥åå¦ä¸ä¿®æ¹
div{width:300px!important;width :340px;margin:0 10px 0 10px}
3ãulæ ç¾å¨Mozillaä¸é»è®¤æ¯æpaddingå¼ç,èå¨IEä¸åªæmarginæå¼æ以å
å®ä¹
ul{margin:0;padding:0;}
å°±è½è§£å³å¤§é¨åé®é¢ã
4ãå
³äºèæ¬ï¼å¨xhtml1.1ä¸ä¸æ¯ælanguageå±æ§ï¼åªéè¦æ代ç æ¹ä¸º
< type=âtext/javaâ>
å°±å¯ä»¥äº
ä¸ã10ä¸ªä½ æªå¿
ç¥éçCSSæå·§
1ãCSSåä½å±æ§ç®åè§å
ä¸è¬ç¨CSS设å®åä½å±æ§æ¯è¿æ ·åçï¼
以ä¸ä¸ºå¼ç¨çå
容ï¼font-weight:bold;font-style:italic;font-varient:small-caps;
font-size:1em;
line-height:1.5em;
font-family:verdana,sans-serif;
ä½ä¹å¯ä»¥æå®ä»¬å
¨é¨åå°ä¸è¡ä¸å»ï¼
font: bold italic small-caps 1em/1.5em verdana,sans-serif;
2ãåæ¶ä½¿ç¨ä¸¤ä¸ªç±»
ä¸è¬åªè½ç»ä¸ä¸ªå
ç´ è®¾å®ä¸ä¸ªç±»ï¼Classï¼ï¼ä½è¿å¹¶ä¸æå³çä¸è½ç¨ä¸¤ä¸ªãäºå®ä¸ï¼ä½ å¯ä»¥è¿æ ·ï¼
â¦
åæ¶ç»På
ç´ ä¸¤ä¸ªç±»ï¼ä¸é´ç¨ç©ºæ ¼æ ¼å¼ï¼è¿æ ·æætextåside两个类çå±æ§é½ä¼å å°På
ç´ ä¸æ¥ãå¦æå®ä»¬ä¸¤ä¸ªç±»ä¸çå±æ§æå²çªçè¯ï¼å设置çèµ·ä½ç¨ï¼å³å¨CSSæ件ä¸æ¾å¨åé¢çç±»çå±æ§èµ·ä½ç¨ã
è¡¥å
ï¼å¯¹äºä¸ä¸ªIDï¼ä¸è½è¿æ ·å
â¦
ä¹ä¸è½è¿æ ·å
3ãCSS borderç缺çå¼
é常å¯ä»¥è®¾å®è¾¹ççé¢è²ï¼å®½åº¦åé£æ ¼ï¼å¦ï¼
border: 3px solid #000
è¿ä½æè¾¹çæ¾ç¤ºæ3åç´ å®½ï¼é»è²ï¼å®çº¿ãä½å®é
ä¸è¿éåªéè¦æå®é£æ ¼å³å¯ã
å¦æåªæå®äºé£æ ¼ï¼å
¶ä»å±æ§å°±ä¼ä½¿ç¨ç¼ºçå¼ãä¸è¬å°ï¼Borderç宽度缺çæ¯mediumï¼ä¸è¬çäº3å°4个åç´ ï¼ç¼ºççé¢è²æ¯å
¶ä¸æåçé¢è²ãå¦æè¿ä¸ªå¼æ£å¥½åéçè¯ï¼å°±ä¸ç¨è®¾é£ä¹å¤äºã
4ãCSSç¨äºææ¡£æå°
许å¤ç½ç«ä¸é½æä¸ä¸ªé对æå°ççæ¬ï¼ä½å®é
ä¸è¿å¹¶ä¸éè¦ï¼å 为å¯ä»¥ç¨CSSæ¥è®¾å®æå°é£æ ¼ã
ä¹å°±æ¯è¯´ï¼å¯ä»¥ä¸ºé¡µé¢æå®ä¸¤ä¸ªCSSæ件ï¼ä¸ä¸ªç¨äºå±å¹æ¾ç¤ºï¼ä¸ä¸ªç¨äºæå°ï¼
第1è¡å°±æ¯æ¾ç¤ºï¼ç¬¬2è¡æ¯æå°ï¼æ³¨æå
¶ä¸çmediaå±æ§ã
ä½åºè¯¥å¨æå°CSSä¸åä»ä¹ä¸è¥¿å¢ï¼ä½ å¯ä»¥æ设计æ®éCSSçæ¹æ³æ¥è®¾å®å®ã设计çåæ¶å°±å¯ä»¥æè¿ä¸ªCSS设ææ¾ç¤ºCSSæ¥æ£æ¥å®çææãä¹è®¸ä½ ä¼ä½¿ç¨ display: none è¿ä¸ªå½ä»¤æ¥å
³æä¸äºè£
饰å¾çï¼åå
³æä¸äºå¯¼èªæé®ã
温馨提示:内容为网友见解,仅供参考