div+css²¼¾Ö
1.È«²¿µÄ´úÂë¾ùÔÚÒ»¸öDIVÈÝÆ÷(ÎÒÔÝʱÕâÑù³Æºô) HeadÀïÃæ,ÎÒÃÇÀ´¿´¿´HeadµÄд·¨
#Head{
text-align:center;
}
ΪʲôHeadÇ°ÃæÓÐÒ»¸ö"#"ºÅÄØ?
¶øÓеÄÈ´ÊÇÔÚÇ°Ãæ¼ÓÒ»¸ö"£®"±ÈÈç "£®Head",ÓÐʱºòдcssµÄʱºò¸É´àʲôҲ²»¼Ó,±ÈÈç td,body,ËûÃÇÓÐÊ²Ã´Çø±ð,¾ßÌåÔõôÓÃ,Èç¹û×ÐϸÄã¾Í»á·¢ÏÖÔÚHTML´úÂëµÄDIVÈÝÆ÷ÀïÃæ,ÓеÄÊÇ <div id="Head"></div> ¶øÓеÄÊÇÕâÑù <div class="HackBox"></div>
´ÓidºÍclass×ÖÃæÉϵÄÒâ˼,ÎÒÃÇÒ²ÒѾÁ˽âÁË,id¾ßÓÐΨһÐÔ,¶øclassÊÇÒ»¸öÀà,ÊÊÓÃÓڿɶà´ÎÖØ¸´Ê¹ÓõÄÈÝÆ÷,¶øÇ°ÃæÊ²Ã´Ò²²»´øµÄ,±ãÊÇ CSSÀïĬÈϵÄͨÓÃÓÚHTML´úÂëµÄÃèÐð,¼´¶ÔHTMLÀïµÄ´úÂëÆðÈ«¾Ö×÷ÓÃ,±ÈÈç td,±ãÊǶÔHTML±í¸ñÀïÃæµÄÈ«²¿ÁÐÆð×÷ÓÃ,text-align:centerÊÇÖ¸ÔÚ´ËÈÝÆ÷ÀïÃæµÄÎÄ×ÖÈ«²¿¾ÓÖÐ¶ÔÆë,ÎÒÃÇ×¢Òâµ½,ÐкóÃæ»¹ÓÐÒ»¸ö·ÖºÅ ";",
Óï·¨ text-align : left | right | center | justify
ȡֵ˵Ã÷£º
left : ĬÈÏÖµ¡£×ó¶ÔÆë
right : ÓÒ¶ÔÆë
center : ¾ÓÖÐ¶ÔÆë
justify : Á½¶Ë¶ÔÆë
2.HeadTop
#Head #HeadTop{
position:relative;
width:760px;
margin:10px auto 10px;
text-align:left;
}
Ϊʲô#HeadTopÇ°Ãæ»áÓÐÒ»¸ö#Head?
ÎÒÃÇ·¢ÏÖ#headTopÊÇǶÌ×ÔÚ#HeadÀïÃæµÄ,ΪÁËHeadÀïÃæµÄÉèÖÃÔÚHeadTopÀïÃæÍ¬ÑùÉúЧ,½«HeadTop·ÅÔÚÁËHeadºóÃæ
position : static | absolute | fixed | relative
ȡֵ£º
static : ĬÈÏÖµ¡£ÎÞÌØÊⶨ룬¶ÔÏó×ñÑHTML¶¨Î»¹æÔò
absolute : ½«¶ÔÏó´ÓÎĵµÁ÷ÖÐÍϳö£¬Ê¹Óà left £¬ right £¬ top £¬ bottom µÈÊôÐÔÏà¶ÔÓÚÆä×î½Ó½üµÄÒ»¸ö×îÓж¨Î»ÉèÖõĸ¸¶ÔÏó½øÐоø¶Ô¶¨Î»¡£Èç¹û²»´æÔÚÕâÑùµÄ¸¸¶ÔÏó£¬ÔòÒÀ¾Ý body ¶ÔÏó¡£¶øÆä²ãµþͨ¹ý z-index ÊôÐÔ¶¨Òå
fixed :δ֧³Ö¡£¶ÔÏó¶¨Î»×ñ´Ó¾ø¶Ô(absolute)·½Ê½¡£µ«ÊÇÒª×ñÊØÒ»Ð©¹æ·¶
relative :¶ÔÏ󲻿ɲãµþ£¬µ«½«ÒÀ¾Ý left £¬ right £¬ top £¬ bottom µÈÊôÐÔÔÚÕý³£ÎĵµÁ÷ÖÐÆ«ÒÆÎ»ÖÃ
width : auto | length
auto : ĬÈÏÖµ¡£ÎÞÌØÊⶨ룬¸ù¾ÝHTML¶¨Î»¹æÔò·ÖÅä
length : Óɸ¡µãÊý×ֺ͵¥Î»±êʶ·û×é³ÉµÄ³¤¶ÈÖµ | °Ù·ÖÊý¡£°Ù·ÖÊýÊÇ»ùÓÚ¸¸¶ÔÏóµÄ¿í¶È¡£²»¿ÉΪ¸
Ïà¹ØÎĵµ£º
DOCTYPE Ó°Ïì CSS ´¦Àí
Firefox: div ÉèÖà margin-left, margin-right Ϊ auto ʱÒѾ¾ÓÖÐ, IE ²»ÐÐ
Firefox: body ÉèÖà text-align ʱ, div ÐèÒªÉèÖà margin: auto(Ö÷ÒªÊÇ margin-left,margin-right) ·½¿É¾ÓÖÐ
Firefox: ÉèÖà padding ºó, div »áÔö¼Ó height ºÍ width, µ« IE ²»»á, ¹ÊÐèÒªÓà !important ¶àÉèÒ»¸ö heig ......
Ò»¡¢CSS HACK
ÒÔÏÂÁ½ÖÖ·½·¨¼¸ºõÄܽâ¾öÏÖ½ñËùÓÐHACK.
1, !important
Ëæ×ÅIE7¶Ô!importantµÄÖ§³Ö, !important ·½·¨ÏÖÔÚÖ»Õë¶ÔIE6µÄHACK.(×¢Òâд·¨.¼ÇµÃ¸ÃÉùÃ÷λÖÃÐèÒªÌáǰ.)
<style>
#wrapper
{
width: 100px!important; /* IE7+FF */
width: 80px; /* IE6 */
}
</style>
2, IE6/IE77¶ÔFireFox
*+ht ......
±¾½Ì³ÌΪwww.sw-web.cnÍøÒ³Éè¼ÆÑ§ÔºÍÆ¼öÎÄÕÂ
Èç¹ûÄãÏë³¢ÊÔһϲ»Óñí¸ñÀ´ÅŰæÍøÒ³£¬¶øÊÇÓÃCSSÀ´ÅŰæÄãµÄÍøÒ³£¬Ò²¾ÍÊdz£ÌýµÄÓÃDIVÀ´±àÅÅÄãµÄÍøÒ³½á¹¹£¬ÓÖ»òÕß˵ÄãÏëÑ§Ï°ÍøÒ³±ê×¼Éè¼Æ£¬ÔÙ»òÕß˵ÄãµÄÉÏ˾ҪÄã¸Ä±ä´«Í³µÄ±í¸ñÅŰ淽ʽ£¬Ìá¸ßÆóÒµ¾ºÕùÁ¦£¬ÄÇôÄãÒ»¶¨Òª½Ó´¥µ½µÄÒ»¸ö֪ʶµã¾ÍÊÇCSSµÄºÐ×Óģʽ£¬Õâ¾ÍÊÇDIVÅŰæµÄºËÐÄË ......
Èç¹ûÄãÊÇÍøÕ¾Ç°¶Ë¿ª·¢ÈËÔ±£¬ÄÇô¶ÔÄãÀ´Ëµ£¬Ò²Ðí×öÒ»¸öƯÁÁµ¼º½²Ëµ¥»áºÜµÃÐÄÓ¦ÊÖ¡£±¾ÎÄҪΪ´ó¼Ò×ܽá¸÷ÖÖµ¼º½²Ëµ¥µÄ×ÊÔ´£¬ÒÔ±ãÈôó¼ÒµÄÍøÕ¾Ç°¶Ë¿ª·¢µÄ¹¤×÷¸ü
·½±ã¸ü¿ìËÙ£¬Ö»ÒªÑ¡ÔñÏֳɵÄÀý×ӾͿÉÒÔÓ¦ÓÃÓÚ×Ô¼ºµÄÍøÕ¾ÁË¡£±¾ÎÄÊÕ¼¯µÄÕâЩ×ÊÔ´£¬´Ó·Ç³£¼òµ¥µÄHTMLºÍCSSµ¼º½²Ëµ¥£¬µ½·Ç³£¸´ÔӺ͸߼¶µÄ
JQuer ......