css3ÈëÃÅ

ÈçºÎʹÓÃonly-childÑ¡ÔñÆ÷

×ÖºÅ+ ×÷Õߣº À´Ô´£º 2014-11-16 21:49 ÎÒÒªÆÀÂÛ( )

Èç¹û²ÉÓÃÈçÏÂËùʾµÄ·½·¨½áºÏÔËÓÃnth-childÑ¡ÔñÆ÷Óënth-last-childÑ¡ÔñÆ÷£¬¿ÉÒÔÖ¸¶¨µ±Ä³¸ö¸¸ÔªËØÖÐÖ»ÓÐÒ»¸öÔªËØʱ²ÅʹÓõÄÑùʽ¡£

only-childÑ¡ÔñÆ÷

ʵÏÖͼʾЧ¹ûµÄHTML´úÂ룺

<ul>
 <li>ÏîÄ¿Áбí1</li>
</ul>
<ul>
 <li>ÏîÄ¿Áбí1</li>
 <li>ÏîÄ¿Áбí2</li>
</ul>

nth-childÑ¡ÔñÆ÷Óënth-last-childÑ¡ÔñÆ÷µÄÔËÓãº

li:nth-child(1):nth-last-child(1) { background:#06F; color:#FFF; }

ʹÓÃonly-childÀ´ÊµÏÖЧ¹ûµÄCSS´úÂ룺

li:only-child { background:#06F; color:#FFF; }

¡¡

1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

Ïà¹ØÎÄÕÂ
  • divcssÈëÃÅÊÓƵ½Ì³Ì-DIVCSS²¼¾ÖµÚ6¿Î-CSSÂ˾µµÄÓ¦ÓÃ

    divcssÈëÃÅÊÓƵ½Ì³Ì-DIVCSS²¼¾ÖµÚ6¿Î-CSSÂ˾µµÄÓ¦ÓÃ

    2015-09-30 11:41

  • divcssÈëÃÅÊÓƵ½Ì³Ì-DIVCSS²¼¾ÖµÚ5¿Î-ÓÃCSSÖÆ×÷ƯÁÁµÄ²Ëµ¥

    divcssÈëÃÅÊÓƵ½Ì³Ì-DIVCSS²¼¾ÖµÚ5¿Î-ÓÃCSSÖÆ×÷ƯÁÁµÄ²Ëµ¥

    2015-09-30 11:40

  • divcssÈëÃŽ̳Ì-DIVCSS²¼¾ÖµÚ4¿Î-ÉèÖÃÒ³ÃæºÍä¯ÀÀÆ÷µÄÔªËØ

    divcssÈëÃŽ̳Ì-DIVCSS²¼¾ÖµÚ4¿Î-ÉèÖÃÒ³ÃæºÍä¯ÀÀÆ÷µÄÔªËØ

    2015-09-30 11:40

  • divcssÈëÃŽ̳Ì-DIVCSS²¼¾ÖµÚ3¿Î-ÉèÖñí¸ñÓë±íµ¥µÄÑùʽ

    divcssÈëÃŽ̳Ì-DIVCSS²¼¾ÖµÚ3¿Î-ÉèÖñí¸ñÓë±íµ¥µÄÑùʽ

    2015-09-30 11:38

ÍøÓѵãÆÀ
Ê