¿ìËÙÒµÎñͨµÀ

CSSʵÀý:ÈÕÆÚ´¹Ö±ÅÅÁеÄÁ½ÖÖ¼¼ÇÉ

×÷Õß ØýÃû¼¼Êõ À´Ô´ CSS¼¼Êõ ä¯ÀÀ ·¢²¼Ê±¼ä 2012-03-02

LearningjQuery.com ²©¿ÍÌû×ÓÁбíµÄ×ó±ßÓÐÒ»¸öºÜ¿áµÄÈÕÆÚ£¬Èçͼ£º

´ÓͼÖÐÎÒÃÇ¿´µ½£¬“2009”´¹Ö±ÅÅÁÐÔÚÓҲࡣÓÃFirebug²é¿´ÔªËØ£¬Îı¾“2009”³öÏÖÔÚhtml½á¹¹Ö®ÖУ¬±¾ÎĽéÉÜʵÏÖÕâÖÖЧ¹ûµÄÁ½ÖÖ·½·¨¡£

Ò»¡¢ÀûÓÃSprite¼¼ÊõÀ´ÊµÏÖ

ÆäʵÏÖ¹ý³ÌÒÑÓÐChris Coyier ÔÚ¡¶Date Display Technique with Sprites¡·Ò»ÎÄÖÐ×÷ÁËÏêϸ½éÉÜ£¬ÕâÀï°ÑÆäʵÏÖ¹ý³Ì×÷Ò»¸ö¼òµ¥µÄÃèÊö¡£ºÜÏÔÈ»£¬ÎÒÃDz»Ï£Íûÿһ¸öÈÕÆÚÓÃÒ»Õŵ¥¶ÀµÄͼƬ£¬Òò´Ë£¬½«ÆäÕûºÏµ½Ò»ÕÅͼƬ֮ÉÏ£¬°²ÅÅÄê¡¢Ô¡¢ÈÕÔÚͼƬµÄ²»Í¬ÇøÓò£¬Èçͼ£º

1¡¢Html

Ò³ÃæÖÐhtml½á¹¹ÈçÏ£º

<div class="postdate">
        <div class="month m-06">Jun</div>
        <div class="day d-30">30</div>
        <div class="year y-2009">2009</div>
</div>

.postdateÈÝÆ÷°üº¬Èý¸öÇøÓò£¬·Ö±ð¶ÔÓ¦ÄêÔ**Õ£¬ÕâÑùºÜºÃµÄ±£Ö¤ÁËÓïÒåÉϵÄÍêÕûÐÔ¡£

ÔÚÀàËÆwordpressÕâÑùµÄCMSϵͳÖУ¬Æäºó¶Ë´úÂëÊÇÕâÑùµÄ£º

<div class="postdate">
        <div class="month m-<?php the_time(''m'') ?>"><?php the_time(''M'') ?></div>
        <div class="day d-<?php the_time(''d'') ?>"><?php the_time(''d'') ?></div>
        <div class="year y-<?php the_time(''Y'') ?>"><?php the_time(''Y'') ?></div>
</div>

2¡¢Css

cssÊÇspriteÕæÕý·¢»Ó×÷Óõĵط½£¬ÀûÓÃhtmlÖеĶ¨ÒåµÄclassÊôÐÔ£¬ÈöÔÓ¦µÄͼƬµÃÒÔÏÔʾ¡£

Ê×ÏÈ£¬ÈÃclassÊôÐÔΪ.postdateµÄÈÝÆ÷Ïà¶Ô¶¨Î»£¬ÕâÑù°üº¬ÆäÖеÄÈý¸öÇøÓò¾Í»á¾ø¶Ô¶¨Î»£¬²¢Ê¹ÓÃͬһÕű³¾°Í¼Æ¬¡£ÉèÖø÷×ԵĿí¶ÈºÍ¸ß¶È£¬²¢½«ÎÄ×ÖÒƳöÒÔÏÔʾ±³¾°Í¼Æ¬¡£

È»ºó£¬¶¨Òåÿ¸öÔ£¨12£©¡¢Ã¿Ì죨31£©¡¢Ã¿Ä꣨°´10Äê¼Æ£©¾ßÌåµÄ±³¾°Î»Öã¬ÒÔÏÔʾÓëÆäÏà¶ÔÓ¦µÄͼƬ¡£

.postdate {
  position: relative;
  width: 50px;
  height: 50px;
  float: left;
}
.month, .day, .year {
  position: absolute;
  text-indent: -1000em;
  background-image: url(/wp-content/themes/ljq/images/dates.png);
  background-repeat: no-repeat;
}
.month { top: 2px; left: 0; width: 32px; height: 24px;}
.day { top: 25px; left: 0; width: 32px; height: 25px;}
.year { bottom: 0; right: 0; width: 17px; height: 48px;}
 
.m-01 { background-position: 0 4px;}
.m-02 { background-position: 0 -28px;}
.m-03 { background-position: 0 -57px;}
... more like this ...
 
.d-01 { background-position: -50px 0;}
.d-02 { background-position: -50px -31px;}
.d-03 { background-position: -50px -62px;}
... more like this ...
 
.y-2006 { background-position: -150px 0;}
.y-2007 { background-position: -150px -50px;}
.y-2008 { background-position: -150px -100px;}
... more like this ...

ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£º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ºÅ