如何在wordpress中做出如下样式的日期图标呢?

第一步,准备背景图片
用Photoshop类似的软件做出一张如下的图片:
第二步,在wordpress中调用日期
写出如下代码:
<div class="post-date">
<div class="month"><?php the_time('M') ?></div>
<div class="day"><?php the_time('d') ?></div>
</div>
如果你要使用上面的代码,自己用键盘敲出来,不要粘贴拷贝,这样引号部分会出错。下面我来解释php部分的代码是什么意思。
<?php the_time('M') ?>:调用月份
<?php the_time('d') ?>:调用日期
第三步,用CSS样式化
.post-date{float: left; display: inline; margin: 0 10px 0 0; background: url(images/date_button_template.gif) no-repeat;}
date_button_template.gif是刚才我们做好的背景图片的名字,它应该是放在images文件夹里面的,所以我们使用的路径是images/date_button_template.gif,这个路径一定要写对,要不图片显示不出来。
下一篇:什么时候打开你的电脑?
-
|1F
八月 17, 2009 5:00 上午我想问这些代码在哪个位置加?我已经打开了single.php,加在最前部。但是没有效果,还有图片url可以用在线的吗?比如http://startwmlife.com/wp-content/uploads/2009/06/date_button_template.gif
background: url(http://startwmlife.com/wp-content/uploads/2009/06/date_button_template.gif
) no-repeat;
可以吗?
回复
}
这篇文章有3个评论. 留下评论