¿ìËÙÒµÎñͨµÀ

CSS3µÄÓÅÊÆÒÔ¼°ÍøÒ³Éè¼ÆʦÈçºÎʹÓÃCSS3¼¼Êõ

×÷Õß ØýÃû¼¼Êõ À´Ô´ CSS¼¼Êõ ä¯ÀÀ ·¢²¼Ê±¼ä 2012-03-02
½Úµã)£¬ÔÚÑùʽ±íÖж¨ÒåÏÂÃæµÄÑùʽ¾Í×ã¹»ÁË£º

1
2
3
div~img {
    border: 1px solid #ccc;
}

ä¯ÀÀÆ÷Ö§³Ö£ºËùÓеÄÖ÷Òªä¯ÀÀÆ÷¶¼Ö§³ÖÕâ¸öͨÓõÄÐÖµÜÑ¡ÔñÆ÷³ýÁËÎÒÃÇ×î°®µÄIE6£¡

αÀà

»òÐíÔÚCSS3ÖÐÔö¼Ó×î¶àµÄ¾ÍÊÇеÄαÀàÁË£¬ÕâÀïÊÇһЩ×îÓÐȤºÍ×îÓÐÓõģº

  • :nth-child(n)
    ÈÃÄã»ùÓÚÔªËØÔÚ¸¸½ÚµãµÄ×ÓÔªËصÄÁбíλÖÃÀ´Ö¸¶¨ÔªËØ¡£Äã¿ÉÒÔÊÇÓÃÊý×Ö¡¢Êý×Ö±í´ïʽ»òodd ºÍeven ¹Ø¼ü´Ê(¶Ô°ßÂíÑùʽµÄÁбíºÜÍêÃÀ)¡£ËùÒÔÈç¹ûÄãÏëÆ¥ÅäÔÚµÚËĸöÔªËØÖ®ºóµÄÒ»¸ö3¸öÔªËصķÖ×飬Äã¿ÉÒÔ¼òµ¥µÄÕâÑùʹÓãº

     

    :nth-child(3n+4) { background-color: #ccc; }/*Æ¥ÅäµÚ4,7,10,13,16,19...¸öÔªËØ*/
  • :nth-last-child(n)
    ÓëÉϸöÑ¡ÔñÆ÷µÄ˼ÏëͬÑù£¬µ«ÊÇ´ÓºóÃæÆ¥ÅäÔªËØ£¨µ¹Ðò£©£¬±ÈÈ磬ΪÁËÖ¸¶¨Ò»¸ödivÀïÃæµÄ×îºóÁ½¸ö¶ÎÂ䣬ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÃæµÄÑ¡ÔñÆ÷£º

     

    div p:nth-last-child(-n+2)
  • :last-child
    Æ¥ÅäÒ»¸ö¸¸½ÚµãϵÄ×îºóÒ»¸ö×ÓÔªËØ£¬µÈͬÓÚ:nth-last-child(1)
  • :checked
    Æ¥ÅäÑ¡ÔñµÄÔªËØ£¬±ÈÈ縴ѡ¿ò
  • :empty
    Æ¥Åä¿ÕÔªËØ£¨Ã»ÓÐ×ÓÔªËØ£©¡£
  • :not(s)
    Æ¥ÅäËùÓв»·ûºÏÖ¸¶¨ÉùÃ÷(s)µÄÔªËØ¡£±ÈÈ磬Èç¹ûÄãÏëÈÃËùÓеÄûÓÐʹÓÔlead”ÀàµÄ¶ÎÂäµÄÏÔʾΪºÚÉ«£¬¿ÉÒÔÕâÑùд£º
    p:not([class*="lead"]) { color: black; }
    .

Andrea Gandino ÔÚËûµÄÍøÕ¾ÉÏʹÓÃ:last-child ΪѡÔñÆ÷Ö¸¶¨Ã¿ÆªÈÕÖ¾µÄ×îºóÒ»¸ö¶ÎÂ䣬²¢½«ÆäµÄÍâ¼ä¾à(margin)ÉèÖÃΪ0:

css3-αÀà

1
2
3
#primary .text p:last-child {
    margin: 0;
    }

ä¯ÀÀÆ÷Ö§³Ö: WebkitºËÐĺÍOpera ä¯ÀÀÆ÷Ö§³ÖËùÓÐеÄCSS3 αÀ࣬Firefox 2 ºÍ3 (GeckoºËÐÄ) Ö»Ö§³Ö:not(s), :last-child, :o nly-child, :root, :empty, :target, :checked, :enabled ºÍ:disabled£¬µ«ÊÇFirefox 3.5 ½«¸ü¼Ó¹ã·ºµÄÖ§³ÖCSS3 Ñ¡ÔñÆ÷¡£TridentºËÐÄä¯ÀÀÆ÷(Internet Explorer)ÊÂʵÉϲ»Ö§³ÖÕâЩαѡÔñÆ÷¡£

αԪËØ

ÔÚCSS3ÖÐΨһÒýÈëµÄαԪËØÊÇ::selection.Ëü¿ÉÒÔÈÃÄãÖ¸¶¨±»Óû§¸ßÁÁ£¨Ñ¡ÖУ©µÄÔªËØ¡£

ä¯ÀÀÆ÷Ö§³Ö: ĿǰûÓÐÈκÎÒ»¿îInternet Explorer »òFirefox ä¯ÀÀÆ÷Ö§³Ö::selection αԪËØ¡£Safari, Opera ºÍChrome ¾ùÖ§³Ö¡£

À©Õ¹ÔĶÁ

  • Selectors Level

ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»!

·ÖÏíµ½£º ¸ü¶à

Copyright ©1999-2011 ÏÃÃÅÁèÖڿƼ¼ÓÐÏÞ¹«Ë¾ ÏÃÃÅÓÅͨ»¥Áª¿Æ¼¼¿ª·¢ÓÐÏÞ¹«Ë¾ All rights reserved

µØÖ·(ADD)£ºÏÃÃÅÈí¼þÔ°¶þÆÚÍûº£Â·63ºÅ701E£¨¶«ÄÏÈÚͨÅÔ£© Óʱà(ZIP)£º361008

µç»°£º0592-5908028 ´«Õ棺0592-5908039 ×ÉѯÐÅÏ䣺web@lingzhong.cn ×ÉѯOICQ£º173723134

¡¶ÖлªÈËÃñ¹²ºÍ¹úÔöÖµµçÐÅÒµÎñ¾­ÓªÐí¿ÉÖ¤¡·ÃöB2-20100024  ICP±¸°¸:ÃöICP±¸05037997ºÅ