1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 带时间轴的文章归档的html页面 WordPress纯CSS打造时间轴归档页面

带时间轴的文章归档的html页面 WordPress纯CSS打造时间轴归档页面

时间:2020-03-18 17:26:18

相关推荐

带时间轴的文章归档的html页面 WordPress纯CSS打造时间轴归档页面

新建一个page-archive.php模板,框架写好后添加下面的主要循环输出。

DIV

$previous_year = $year = 0;

$previous_month = $month = 0;

$ul_open = false;

$myposts = get_posts('numberposts=-1&orderby=post_date&order=DESC');

foreach($myposts as $post) :

setup_postdata($post);

$year = mysql2date('Y', $post->post_date);

$month = mysql2date('n', $post->post_date);

$day = mysql2date('j', $post->post_date);

if($year != $previous_year || $month != $previous_month) :

if($ul_open == true) :

echo '';

endif;

echo '

'; echo the_time('Y-m'); echo '

';

echo '

';

$ul_open = true;

endif;

$previous_year = $year; $previous_month = $month;

?>

<?php the_time('Y-m-j'); ?>

CSS

.archive-title{border-bottom:1px #eee solid;position:relative;padding-bottom:4px;margin-bottom:10px}

.archives li a{padding:8px 0;display:block}

.archives li a:hover .atitle:after{background:#428bca}

.archives li a span{display:inline-block;width:100px;font-size:12px;text-indent:20px}

.archives li a .atitle{display:inline-block;padding:0 15px;position:relative}

.archives li a .atitle:after{position:absolute;left:-6px;background:#ccc;height:8px;width:8px;border-radius:6px;top:6px;content:""}

.archives li a .atitle:before{position:absolute;left:-4px;background:#fff;height:12px;width:12px;border-radius:6px;top:6px;content:""}

.archives{position:relative;padding:10px 0}

.archives:before{height:95%;width:4px;background:#e6e6e6;position:absolute;left:100px;content:"";top:30px}

.m-title{position:relative;margin:10px 0;cursor:pointer}

.m-title:hover:after{background:#ff5c43}

.m-title:before{position:absolute;left:94px;background:#fff;height:16px;width:16px;border-radius:8px;top:8px;content:""}

.m-title:after{position:absolute;left:96px;background:#ccc;height:12px;width:12px;border-radius:6px;top:10px;content:""}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。