Õâ¸ö“ä¯ÀÀÆ÷ĬÈÏHTMLµÄCSSÑùʽÊôÐÔ”£¬ÔÚÄãÐèÒª»¹ÔĬÈÏÖµµÄʱºò£¬±È½ÏÓÐÓ᣿ªÊ¼µÄʱºòÓ¦ÓÃͨÅäÑ¡ÔñÆ÷ *
{margin:0;padding:0;}£¬µ±ÐèҪʹÓñ߾àµÄʱºò£¬¾ÍÐèÒª»¹ÔHTMLĬÈÏCSSÖµÁË¡£
µ«Í¨ÅäÑ¡ÔñÆ÷ÔÚ´óÐÍÍøÕ¾µÄ¹¹½¨ÖУ¬Ó°
ÏìÐÔÄÜ£¬¿ÉÒԲο¼52CSS.comµÄÏà¹ØÎÄÕ£¬´ó¼Ò»¹ÊÇÐèÒª½÷É÷һЩ¡£
¡¡¡¡ÒÔÇ°Ò»Ö±ÔÚÕÒÕâ·ÝÎĵµ£¬½ñÌìżȻÔÚw3ÉÏ¿´µ½ÁË¡£³ýÁË
inlineºÍblockµÄ¶¨Ò壬Ö÷ÒªÊÇҪעÒâbody|h1~h6|blockquote|menu|ul|ol|ddµÈ±êÇ©µÄĬÈÏÑùʽ£¨margin
ºÍfont-size£©¡£
Example Source Code [www.52css.com
html, address,
blockquote,
body, dd, div,
dl, dt, fieldset, form,
frame, frameset,
h1, h2, h3, h4,
h5, h6, noframes,
ol, p, ul, center,
dir, hr, menu, pre { display: block }
li { display: list-item }
head &n ......
Õâ¸ö“ä¯ÀÀÆ÷ĬÈÏHTMLµÄCSSÑùʽÊôÐÔ”£¬ÔÚÄãÐèÒª»¹ÔĬÈÏÖµµÄʱºò£¬±È½ÏÓÐÓ᣿ªÊ¼µÄʱºòÓ¦ÓÃͨÅäÑ¡ÔñÆ÷ *
{margin:0;padding:0;}£¬µ±ÐèҪʹÓñ߾àµÄʱºò£¬¾ÍÐèÒª»¹ÔHTMLĬÈÏCSSÖµÁË¡£
µ«Í¨ÅäÑ¡ÔñÆ÷ÔÚ´óÐÍÍøÕ¾µÄ¹¹½¨ÖУ¬Ó°
ÏìÐÔÄÜ£¬¿ÉÒԲο¼52CSS.comµÄÏà¹ØÎÄÕ£¬´ó¼Ò»¹ÊÇÐèÒª½÷É÷һЩ¡£
¡¡¡¡ÒÔÇ°Ò»Ö±ÔÚÕÒÕâ·ÝÎĵµ£¬½ñÌìżȻÔÚw3ÉÏ¿´µ½ÁË¡£³ýÁË
inlineºÍblockµÄ¶¨Ò壬Ö÷ÒªÊÇҪעÒâbody|h1~h6|blockquote|menu|ul|ol|ddµÈ±êÇ©µÄĬÈÏÑùʽ£¨margin
ºÍfont-size£©¡£
Example Source Code [www.52css.com
html, address,
blockquote,
body, dd, div,
dl, dt, fieldset, form,
frame, frameset,
h1, h2, h3, h4,
h5, h6, noframes,
ol, p, ul, center,
dir, hr, menu, pre { display: block }
li { display: list-item }
head &n ......
¡¡¡¡Ïë³ÉΪһÃûCSSר¼Ò£¬½ö½öÊìÁ·Ê¹ÓÃCSSÑ¡Ôñ·û(selectors)ÊÇÔ¶Ô¶²»¹»µÄ¡£»¹ÔÚÓÚ¶Ô¹¤×÷µÄÕûÌå¹æ»®£¬¹¤×÷Á÷³ÌµÄÕÆÎÕÒÔ¼°Ìá¸ßÑùʽ±íµÄ¿Éά»¤ÐÔºÍЧÂÊ¡£ÓÃCSS¿ÉÒÔ´´½¨³öÎÒÃÇÏëÒªµÄÃÀÃî¾øÂ×µÄÍøÕ¾£¬¶øдCSS±¾Éí¾ÍÊÇÒ»ÖÖÏíÊÜ¡£ ÄÇôÎÒÃÇÓ¦¸ÃÈçºÎ´´½¨¸ü¾ßÎüÒýÁ¦µÄÑùʽ±í?ÄãµÄÑùʽ±íÓ¦¸Ã¾ßÓÐÄÄЩÌØÐÔÄØ?ͨ¹ýѧϰ²¢½áºÏÎÒ×Ô¼ºµÄ¹¤×÷¾Ñ飬×ܽá³öÒ»Ì×ÖÆ×÷¾«ÃÀÑùʽ±íµÄºÃ·½·¨¡£
¡¡¡¡Ò»¡¢²»ÒªÈÃCSSÓйý¶àµÄ±ê¼Ç
¡¡¡¡Á´½Ó»òÕßµ¼ÈëÑùʽ±íÌýÆðÀ´ºÃÏñÊÇÒ»ÖÖÎÞÍ·Ð÷µÄ¹¤×÷¡£ÎÒ¿´¹ýºÜ¶àµÄÍøÕ¾¿ª·¢¶¼ÓÐ×ÅÕû½àµÄ¡¢×éÖ¯ÑÏÃܵÄcssÎĵµ£¬µ«ÊÇÂýÂýµÄ£¬ÓÉÓÚ¿ÉÄÜ´ï²»µ½ÔÚ¶ÌÆÚÄÚ¿ìËÙ¸üУ¬»òÕßÀÁµÃÔÙÈ¥¹ÜÀí£¬ÕâʹµÃÏÈÇ°´´½¨µÄ¾«ÖµÄÑùʽ±í±ä³ÉÁËÀ¬»ø¡£Èç¹ûÎÒÃǹ¤×÷ÔÚÐèÒª·¢²¼ÉÏ°ÙÌõÄÚÈݵÄÅÓ´óÍøÕ¾ÉÏÃæ¡£ÒòΪʱ¼äÓÐÏÞ£¬ËùÒÔÄãÐèҪͨ¹ýǶÌ×»òÕßÅÅÁÐcssÀ´½øÐпìËÙÐ޸Ļò¸üС£Ëæ×Åʱ¼äµÄÍÆÒÆ£¬ÕâÖÖÏ°¹ßά³Ö×Å£¬Ö±µ½ÓÐÒ»ÌìÄã±»¸æÖªÕâ¸öÍøÕ¾ÒªÍêÈ«ÍÆ·ÖØÐÂÉè¼Æ¶øÇÒÄãÖ»ÓÐÒ»ÖܵÄʱ¼äÈ¥´´½¨¡£Ò»°ãÀ´Ëµ£¬¸üÐÂÑùʽ±í»¹ËãÊÇÒ»¸ö·Ç³£¼òµ¥µÄ·½·¨£¬³ý·ÇÄ㳤ʱ¼ä¶ÔÍøÕ¾ÁãÉ¢µÄÇøÓò×öÐ޸ģ¬Äã¾Í²»ÄܶÔÍøÕ¾Ñùʽ±í½á¹¹ÓÐÒ»¸öÕûÌåµÄ°ÑÎÕ¡£
¡¡¡¡Á´½Ó»òÕßµ¼ÈëÄãµÄÑùʽ±í²»ÊÇËæÒâµÄÊÂÇé¡£´´½¨¸É¾»Õû½àµÄÑùʽ±í²¢±£³ÖÏÂÈ¥£¬¹ ......
CSS±³¾°ÊôÐÔ
±³¾°ÑÕÉ«ÊôÐÔ(background-color)
Õâ¸öÊôÐÔΪHTMLÔªËØÉ趨±³¾°ÑÕÉ«£¬Ï൱ÓÚHTMLÖÐbgcolorÊôÐÔ¡£
body {background-color:#99FF00;}
ÉÏÃæµÄ´úÂë±íʾBodyÕâ¸öHTMLÔªËصı³¾°ÑÕÉ«ÊÇ´äÂÌÉ«µÄ¡£
±³¾°Í¼Æ¬ÊôÐÔ(background-image)
Õâ¸öÊôÐÔΪHTMLÔªËØÉ趨±³¾°Í¼Æ¬£¬Ï൱ÓÚHTMLÖÐbackgroundÊôÐÔ¡£
<body style="background-image:url(../images/css_tutorials/background.jpg)">
ÉÏÃæµÄ´úÂëΪBodyÕâ¸öHTMLÔªËØÉ趨ÁËÒ»¸ö±³¾°Í¼Æ¬¡£
±³¾°Öظ´ÊôÐÔ(background-repeat)
Õâ¸öÊôÐÔºÍbackground-imageÊôÐÔÁ¬ÔÚÒ»ÆðʹÓ㬾ö¶¨±³¾°Í¼Æ¬ÊÇ·ñÖظ´¡£Èç¹ûÖ»ÉèÖÃbackground-imageÊôÐÔ£¬Ã»ÉèÖÃbackground-repeatÊôÐÔ£¬ÔÚȱʡ״̬Ï£¬Í¼Æ¬¼ÈºáÏòÖظ´£¬ÓÖÊúÏòÖظ´¡£
• repeat-x ±³¾°Í¼Æ¬ºáÏòÖظ´
• repeat-y ±³¾°Í¼Æ¬ÊúÏòÖظ´
• no-repeat ±³¾°Í¼Æ¬²»Öظ´
body {background-image:url(../images/css_tutorials/background.jpg); background- ......
ÎÒÃÇ´Ó52CSS.comÖÐѧϰDivCSSÍøÒ³²¼¾ÖµÄ֪ʶ£¬¿ÉÊÇW3C validationÓÐʱÄÑÒÔ²Ù×÷£¬µ«ÓÃËüÄã¿ÉÒԲ鿴ÓÉ°æÃæÉè¼ÆÒýÆðµÄ²î´í¡£ÑéÖ¤³ÌÐòÅ׳ö´óÁ¿²î´íºÍ¾¯¸æ£¬ËµÃ÷ÄãµÄXHTMLÉÐδÍêÉÆ£¬¿ÉÄÜÎÞ·¨ÔÚ²»Í¬ä¯ÀÀÆ÷Éϱ£³ÖÒ»Ö¹¦ÄÜ¡£ÏÂÃæÊ®¸öϸ΢µÄʧЧÎÊÌâÄÑסÁË´óÅú³ÌÐòÔ±£¬±¾Îľ͸æËßÄãÈçºÎ½â¾ö¡£ÔÚ±¾ÎÄ¿ªÊ¼Ç°½éÉÜһЩʹÓÃW3CÑéÖ¤³ÌÐòʱÐèҪעÒâµÄÎÊÌâ¡£
¡¡1¡¢²»Òªµ£ÐÄÑéÖ¤³ÌÐòµÄ¾¯¸æ£ºÈç¹ûÑéÖ¤³ÌÐò˵·¢ÏÖ12´¦´íÎóÒÔ¼°83´¦¾¯¸æ£¬²»ÒªÀíËü£¬¼ÌÐø½øÐÐÏÂÒ»²½¡£
¡¡¡¡2¡¢Ò»´Î¸üÕýÒ»¸ö´íÎ󣺰´Ë³Ðò½ø
Õ¹¹¤×÷£¬´ÓÉϵ½Ï£¬Ò»´ÎÐÞÕýÒ»¸ö´íÎó¡£HTMLÓÃä¯ÀÀÆ÷´ÓÉϵ½ÏÂä¯ÀÀ£¬ÕâЩ´íÎóÒ²ÊÇ°´Í¬Ñù˳ÐòÏÔʾ¡£
¡¡¡¡3¡¢Ã¿´ÎÐÞÕý´úÂëºóҪˢдúÂ룬ʹËüÃÇ
ÖØÐÂÉúЧ£ºÒ»¸öС´íÎó³£³£»áÒý·¢Ö®ºóÕûÒ³µÄÁ¬´®´íÎó¡£Òò´ËÈç¹û²Ù×÷²»µ±£¬“ÐÞÕý´íÎó”Ò²¿ÉÄÜÒý·¢¸ü¶à´íÎó¡£Ã¿´ÎÐÞÕýºóʹ´úÂëÖØÐÂÉúЧ£¬ÕâÑù¾Í¿ÉÒÔÈ·±£ÍêÈ«
½â¾öÎÊÌâ¡£
¡¡¡¡ÖªµÀÁËÉÏÃæÕâЩ»ù±¾µÄÒì³£Çé¿ö£¬ÏÂÃæÎÒÃǾÍÀ´¿´¿´°æÃæÉè¼ÆÎÞЧµÄ¼¸¸öÔÒò¡£
¡¡¡¡Ò»¡¢div ±êÇ©
δ¹Ø±Õ
¡¡¡¡ÕâÊÇ°æÃæÉè¼ÆʧЧµÄ×î³£¼ûÔÒòÖ®Ò»¡£µ±ÎÒÃÇÁ˽⵽ÕâÊǶàÉÙ¾«Öµİæ¿éÉè¼ÆʧЧµÄ×ï¿ý»öÊ×ʱ£¬×Ü»á´ó³ÔÒ»¾ª¡£¿ªÆôµÄ
......
Internet Explorer 8Ô¤ÉèÊÇÒÔCSS 2.1Ϊ±ê×¼£¬²¢ÐÞÕýÁËÐí¶àInternet Explorer 7µÄCSS Bug£¬ÕâÒâζ×ÅÓÐÒ»²¿·ÝÒÔÍùÒÀ¾ÝIE 7ËùÉè¼ÆµÄÍøÒ³£¬
ÔÚIE 8ÉϵijÊÏÖ»áÓÐËù³öÈ룬ËùÐÒ°ÝIE 7ÏàÈݼìÊÓ¹¦ÄÜËù´Í£¬Ä¿Ç°ÒòʹÓÃIE 8¶øµ¼Ö°æÃæ´íÎóµÄÍøÕ¾²¢²»¶à¡£
µ«Ò»ÖµÒÀÀµIE 7ÏàÈݼìÊÓ¹¦Äܲ¢·Ç³¤¾ÃÖ®¼Æ£¬¾¡Ô罫ÍøÕ¾ÐÞ¸ÄΪIE 8ÏàÈݲÅÊdz¤¾ÃÖ®¼Æ£¬ÒòΪ±Ï¾¹CSSÊdzÖÐø¸üеģ¬ÏÖÔÚ²»¸Ä£¬ÈÕºó´óÐ޵Ļú»á¾Í¸ü´ó¡£
²»ÐÒµÄÊÇ£¬Microsoft¹Ù·½²¢Î´Ìṩ¹ØÓÚIE 7¼°IE 8µÄCSS²îÒì˵Ã÷Îļþ£¬¶¥¶àÖ»ÊǸæËßÎÒÃÇIE 8Ä¿Ç°¸üÇ÷½üÓÚCSS 2.1¶ø·ÇCSS 2.0£¬Òò´Ë±ÊÕßÔÚÔì·ÃÐí¶àÍøÕ¾ºó£¬
¹æÀà³ö8¸ö×î³£¼ûµÄ²îÒ칩¶ÁÕßÃDzο¼¡£
1¡¢Æðʼ×ù標λÖÃ
ÏÈÌìÉÏ£¬IE 7ÓëIE 8ÔÚÔ¤ÉèÍøÒ³°æÃæµÄÆðʼλÖþͲ»Í¬£¬ÒÔÏÂÃæµÄ´úÂëÀ´Ëµ£¬ÔÚIE 7¼°IE 8ÉÏÆôʼµÄλÖþÍÓвîÒì¡£
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div style="height:100px;width:200px; border: solid 1px black"&g ......
¶¯»»ÐÐÎÊÌâ,Õý³£×Ö·ûµÄ»»ÐÐÊDZȽϺÏÀíµÄ,¶øÁ¬ÐøµÄÊý×ÖºÍÓ¢ÎÄ×Ö·û³£³£½«ÈÝÆ÷³Å´ó,ͦÈÃÈËÍ·ÌÛ,ÏÂÃæ½éÉܵÄÊÇCSSÈçºÎʵÏÖ»»Ðеķ½·¨
¶ÔÓÚdiv,pµÈ¿é¼¶ÔªËØ
Õý³£ÎÄ×ֵĻ»ÐÐ(ÑÇÖÞÎÄ×ֺͷÇÑÇÖÞÎÄ×Ö)ÔªËØÓµÓÐĬÈϵÄwhite-space:normal,µ±¶¨ÒåµÄ¿í¶ÈÖ®ºó×Ô¶¯»»ÐÐ
html
<
id="wrap">Õý³£ÎÄ×ֵĻ»ÐÐ(ÑÇÖÞÎÄ×ֺͷÇÑÇÖÞÎÄ×Ö)ÔªËØÓµÓÐĬÈϵÄwhite-space:normal,µ±¶¨Òå< /div
>
css
#wrap{white-space:normal; width:200px; }
1.£¨IEä¯ÀÀÆ÷£©Á¬ÐøµÄÓ¢ÎÄ×Ö·ûºÍ°¢À²®Êý×Ö,ʹÓÃword-wrap
: break-word ;»òÕßword-break:break-all;ʵÏÖÇ¿ÖƶÏÐÐ
#wrap{word-break:break-all; width:200px;}
»òÕß
#wrap{word-wrap:break-word; width:200px;}
<
id="wrap">abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111< /div
>
Ч¹û£º¿ÉÒÔʵÏÖ»»ÐÐ
2.£¨Firefoxä¯ÀÀÆ÷£©Á¬ÐøµÄÓ¢ÎÄ×Ö·ûºÍ°¢À²®Êý×ֵĶÏÐÐ,FirefoxµÄËùÓа汾µÄûÓнâ¾öÕâ¸öÎÊÌâ,ÎÒÃÇÖ»ÓÐÈó¬³ö±ß½çµÄ×Ö·ûÒþ²Ø»òÕß,¸øÈÝÆ÷Ìí¼Ó¹ö¶¯Ìõ
#wrap{word-break:break-all; width:200px; overflow:auto;}
<
id="wrap">abcdefghijklmnabcdefghijklmnabcdefghijklmn111111111< /div
>
......