1ãdivçåç´å±
ä¸é®é¢ vertical-align:middle; å°è¡è·å¢å å°åæ´ä¸ªDIVä¸æ ·é« line-height:200px; ç¶åæå
¥æåï¼å°±åç´å±
ä¸äºã缺ç¹æ¯è¦æ§å¶å
容ä¸è¦æ¢è¡
2ã marginå åçé®é¢ 设置为floatçdivå¨ieä¸è®¾ç½®çmarginä¼å åãè¿æ¯ä¸ä¸ªie6é½åå¨çbugã解å³æ¹æ¡æ¯å¨è¿ä¸ªdivéé¢å ä¸ display:inline; ä¾å¦ï¼ <#div id=âimfloatâ> ç¸åºçcss为 #IamFloat{ float:left; margin:5px;/*IEä¸ç解为10px*/ display:inline;/*IEä¸åç解为5px*/}
3ãæµ®å¨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;
4ãIEä¸å®½åº¦åé«åº¦çé®é¢ 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;}
5ã页é¢çæå°å®½åº¦ min -widthæ¯ä¸ªé常æ¹ä¾¿çCSSå½ä»¤ï¼å®å¯ä»¥æå®å
ç´ æå°ä¹ä¸è½å°äºæ个宽度ï¼è¿æ ·å°±è½ä¿è¯æçä¸ç´æ£ç¡®ãä½IEä¸è®¤å¾è¿ä¸ªï¼èå®å®é
ä¸æwidthå½åæå°å®½åº¦æ¥ä½¿ã为äºè®©è¿ä¸å½ä»¤å¨IEä¸ä¹è½ç¨ï¼å¯ä»¥æä¸ä¸ª<div> æ¾å° <body> æ ç¾ä¸ï¼ç¶å为divæå®ä¸ä¸ªç±», ç¶åCSSè¿æ ·è®¾è®¡ï¼ #container{ min-width: 600px; width:expression(document.body.clientWidth < 600? "600px": "auto" );} 第ä¸ä¸ªmin-widthæ¯æ£å¸¸çï¼ä½ç¬¬2è¡çwidth使ç¨äºJavascriptï¼è¿åªæIEæ认å¾ï¼è¿ä¹ä¼è®©ä½ çHTMLææ¡£ä¸å¤ªæ£è§ãå®å®é
ä¸éè¿Javascriptçå¤ææ¥å®ç°æå°å®½åº¦ã
6ãDIVæµ®å¨IEææ¬äº§ç3è±¡ç´ çbug 左边对象浮å¨ï¼å³è¾¹éç¨å¤è¡¥ä¸ç左边è·æ¥å®ä½ï¼å³è¾¹å¯¹è±¡å
çææ¬ä¼ç¦»å·¦è¾¹æ3pxçé´è·. #box{ float:left; width:800px;} #left{ float:left; width:50%;} #right{ width:50%;} *html #left{ margin-right:-3px; //è¿å¥æ¯å
³é®} <div id="box"> <div id="left"></div> <div id="right"></div> </div>
7ãIEæè¿·èçé®é¢ å½divåºç¨å¤æçæ¶åæ¯ä¸ªæ ä¸åæä¸äºé¾æ¥ï¼DIVçè¿ä¸ªæ¶å容æåçæè¿·èçé®é¢ã æäºå
容æ¾ç¤ºä¸åºæ¥ï¼å½é¼ æ éæ©è¿ä¸ªåºåæ¯åç°å
容确å®å¨é¡µé¢ã 解å³åæ³ï¼å¯¹#layout使ç¨line-heightå±æ§æè
ç»#layout使ç¨åºå®é«å宽ã页é¢ç»æå°½éç®åã
8ãfloatçdivéå;æ¸
é¤æµ®å¨;èªéåºé«åº¦;
â ä¾å¦ï¼<#div id=âfloatAâ ><#div id=âfloatBâ ><#div id=â NOTfloatCâ >è¿éçNOTfloatC并ä¸å¸æ继ç»å¹³ç§»ï¼èæ¯å¸æå¾ä¸æã(å
¶ä¸floatAãfloatBçå±æ§å·²ç»è®¾ç½®ä¸º float:left;) è¿æ®µä»£ç å¨IEä¸æ¯«æ é®é¢ï¼é®é¢åºå¨FFãåå æ¯NOTfloatC并éfloatæ ç¾ï¼å¿
é¡»å°floatæ ç¾éåãå¨ <#div class=âfloatBâ> <#div class=âNOTfloatCâ>ä¹é´å ä¸ < #div class=âclearâ>è¿ä¸ªdivä¸å®è¦æ³¨æä½ç½®ï¼èä¸å¿
é¡»ä¸ä¸¤ä¸ªå
·æfloatå±æ§çdivå级ï¼ä¹é´ä¸è½åå¨åµå¥å
³ç³»ï¼å¦åä¼äº§çå¼å¸¸ã并ä¸å°clearè¿ç§æ ·å¼å®ä¹ä¸ºä¸ºå¦ä¸å³å¯ï¼ .clear{ clear:both;}
â¡ä½ä¸ºå¤é¨ wrapper ç div ä¸è¦å®æ»é«åº¦,为äºè®©é«åº¦è½èªå¨éåºï¼è¦å¨wrapperéé¢å ä¸overflow:hidden; å½å
å«floatç boxçæ¶åï¼é«åº¦èªå¨éåºå¨IEä¸æ æï¼è¿æ¶ååºè¯¥è§¦åIEçlayoutç§æå±æ§(ä¸æ¶çIEåï¼)ç¨zoom:1;å¯ä»¥åå°ï¼è¿æ ·å°±è¾¾å°äºå
¼å®¹ã ä¾å¦æä¸ä¸ªwrapperå¦ä¸å®ä¹ï¼ .colwrapper{ overflow:hidden; zoom:1; margin:5px auto;}
â¢å¯¹äºæç,æ们ç¨å¾æå¤çcssæè¿°å¯è½å°±æ¯float:left.æçæ¶åæ们éè¦å¨næ çfloat divåé¢åä¸ä¸ªç»ä¸çèæ¯,è¬å¦: <div id=âpageâ> <div id=âleftâ></div> <div id=âcenterâ></div> <div id=ârightâ></div> </div> æ¯å¦æ们è¦å°pageçèæ¯è®¾ç½®æèè²,以达å°ææä¸æ çèæ¯é¢è²æ¯èè²çç®ç,ä½æ¯æ们ä¼åç°éçleft center rightçåä¸æé¿,è pageå±
ç¶ä¿åé«åº¦ä¸å,é®é¢æ¥äº,åå å¨äºpageä¸æ¯floatå±æ§,èæ们çpageç±äºè¦å±
ä¸,ä¸è½è®¾ç½®æfloat,æ以æ们åºè¯¥è¿æ ·è§£å³ <div id=âpageâ> <div id=âbgâ style=âfloat:left;width:100%â> <div id=âleftâ></div> <div id=âcenterâ></div> <div id=ârightâ></div> </div> </div> ååµå
¥ä¸ä¸ªfloat leftè宽度æ¯100%çDIV解å³ä¹
â£ä¸è½float éå(é常éè¦!) å
³äº clear float çåçå¯åè§ [How To Clear Floats Without Structural Markup],å°ä»¥ä¸ä»£ç å å
¥Global CSS ä¸,ç»éè¦éåçdivå ä¸ class="clearfix" å³å¯,屡è¯ä¸ç½. /* Clear Fix */ .clearfix:after { content:"."; display:block; height:0; clear:both; visibility:hidden; } .clearfix { display:inline-block; } /* Hide from IE Mac */ .clearfix {display:block;} /* End hide from IE Mac */ /* end of clearfix */ æè
è¿æ ·è®¾ç½®ï¼.hackbox{ display:table; //å°å¯¹è±¡ä½ä¸ºåå
ç´ çº§çè¡¨æ ¼æ¾ç¤º}
11ãé«åº¦ä¸éåº é«åº¦ä¸éåºæ¯å½å
å±å¯¹è±¡çé«åº¦åçååæ¶å¤å±é«åº¦ä¸è½èªå¨è¿è¡è°èï¼ç¹å«æ¯å½å
å±å¯¹è±¡ä½¿ç¨margin æpaddign æ¶ã ä¾ï¼ #box {background-color:#eee; } #box p {margin-top: 20px;margin-bottom: 20px; text-align:center; } <div id="box"> <p>p对象ä¸çå
容</p> </div> 解å³æ¹æ³ï¼å¨P对象ä¸ä¸åå 2个空çdiv对象CSS代ç ï¼.1{height:0px;overflow:hidden;}æè
为DIVå ä¸ borderå±æ§ã
12ãIE6ä¸ä¸ºä»ä¹å¾çä¸æ空é产ç解å³è¿ä¸ªBUGçæ¹æ³ä¹æå¾å¤,å¯ä»¥æ¯æ¹åhtmlçæç,æè
设置img 为display:block æè
设置vertical-align å±æ§ä¸º vertical-align:top | bottom |middle |text-bottom é½å¯ä»¥è§£å³.
13ãå¦ä½å¯¹é½ææ¬ä¸ææ¬è¾å
¥æ¡ å ä¸ vertical-align:middle; <style type="text/css"> <!-- input { width:200px; height:30px; border:1px solid red; vertical-align:middle; } --> </style>
14ãwebæ åä¸å®ä¹idä¸classæä»ä¹åºå«å ä¸.webæ åä¸æ¯ä¸å®¹è®¸éå¤IDç,æ¯å¦ div id="aa" ä¸å®¹è®¸éå¤2次,èclass å®ä¹çæ¯ç±»,ç论ä¸å¯ä»¥æ ééå¤, è¿æ ·éè¦å¤æ¬¡å¼ç¨çå®ä¹ä¾¿å¯ä»¥ä½¿ç¨ä». äº.å±æ§çä¼å
级é®é¢ ID çä¼å
级è¦é«äºclass,çä¸é¢çä¾åä¸.æ¹ä¾¿JSç客æ·ç«¯èæ¬,å¦æå¨é¡µé¢ä¸è¦å¯¹æ个对象è¿è¡èæ¬æä½,é£ä¹å¯ä»¥ç»ä»å®ä¹ä¸ä¸ªID,å¦ååªè½å©ç¨éå页é¢å
ç´ å ä¸æå®ç¹å®å±æ§æ¥æ¾å°å®,è¿æ¯ç¸å¯¹æµªè´¹æ¶é´èµæº,è¿è¿ä¸å¦ä¸ä¸ªIDæ¥å¾ç®å.
15ãLIä¸å
容è¶
è¿é¿åº¦å以çç¥å·æ¾ç¤ºçæ¹æ³ æ¤æ¹æ³éç¨ä¸IEä¸OPæµè§å¨ <style type="text/css"> <!-- li { width:200px; white-space:nowrap; text-overflow:ellipsis; -o-text-overflow:ellipsis; overflow: hidden; } --> </style>
16ã为ä»ä¹webæ åä¸IEæ æ³è®¾ç½®æ»å¨æ¡é¢è²äº 解å³åæ³æ¯å°bodyæ¢æhtml <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <style type="text/css"> <!-- html { scrollbar-face-color:#f6f6f6; scrollbar-highlight-color:#fff; scrollbar-shadow-color:#eeeeee; scrollbar-3dlight-color:#eeeeee; scrollbar-arrow-color:#000; scrollbar-track-color:#fff; scrollbar-darkshadow-color:#fff; } --> </style>
17ã为ä»ä¹æ æ³å®ä¹1pxå·¦å³é«åº¦çå®¹å¨ IE6ä¸è¿ä¸ªé®é¢æ¯å 为é»è®¤çè¡é«é æç,解å³çæ¹æ³ä¹æå¾å¤,ä¾å¦:overflow:hidden | zoom:0.08 | line-height:1px
18ãæä¹æ ·æè½è®©å±æ¾ç¤ºå¨FLASHä¹ä¸å¢ 解å³çåæ³æ¯ç»FLASH设置éæ <param name="wmode" value="transparent" />
19ãææ ·ä½¿ä¸ä¸ªå±åç´å±
ä¸äºæµè§å¨ä¸è¿éæ们使ç¨ç¾åæ¯ç»å¯¹å®ä½,ä¸å¤è¡¥ä¸è´å¼çæ¹æ³,è´å¼ç大å°ä¸ºå
¶èªèº«å®½åº¦é«åº¦é¤ä»¥äº <style type="text/css"> <!-- div { position:absolute; top:50%; lef:50%; margin:-100px 0 0 -100px; width:200px; height:200px; border:1px solid red; } --> </style>
tableä¸divè¿ä¸ªå¥ä¸æ¯å¾æ¸
æ¥äºï¼åºä¸ºä¸è¬ç¨äºtableå°±ä¸ç¨diväºï¼ç¨äºdivå°±ä¸ç¨tableäº
æé纳ï¼å¦æè¿æä¸æç½çï¼å¯ä»¥ç»§ç»è¿½é®æã