给标签云添加发光效果

http://www.viagrasansordonnancefr.com/

一找到主题内部的style.css文件,用编辑器打开,往底部添加以下css代码:

/*外加标签样式*/
@-webkit-keyframes bigAssButtonPulse {
  from { background-color: #1e6a0f; -webkit-box-shadow: 0 0 25px #333; }
  50% { background-color: #39ba1f; -webkit-box-shadow: 0 0 75px #39ba1f; }
  to { background-color: #1e6a0f; -webkit-box-shadow: 0 0 25px #333; }
}

@-webkit-keyframes greenPulse {
  from { background-color: #1e6a0f; -webkit-box-shadow: 0 0 9px #333; }
  50% { background-color: #39ba1f; -webkit-box-shadow: 0 0 27px #39ba1f; }
  to { background-color: #1e6a0f; -webkit-box-shadow: 0 0 9px #333; }
}

@-webkit-keyframes bluePulse {
  from { background-color: #036075; -webkit-box-shadow: 0 0 9px #333; }
  50% { background-color: #2daebf; -webkit-box-shadow: 0 0 27px #2daebf; }
  to { background-color: #036075; -webkit-box-shadow: 0 0 9px #333; }
}

@-webkit-keyframes redPulse {
  from { background-color: #8c2305; -webkit-box-shadow: 0 0 9px #333; }
  50% { background-color: #e33100; -webkit-box-shadow: 0 0 27px #e33100; }
  to { background-color: #8c2305; -webkit-box-shadow: 0 0 9px #333; }
}

@-webkit-keyframes magentaPulse {
  from { background-color: #470123; -webkit-box-shadow: 0 0 9px #333; }
  50% { background-color: #a9014b; -webkit-box-shadow: 0 0 27px #a9014b; }
  to { background-color: #470123; -webkit-box-shadow: 0 0 9px #333; }
}

@-webkit-keyframes orangePulse {
  from { background-color: #b84c04; -webkit-box-shadow: 0 0 9px #333; }
  50% { background-color: #ff5c00; -webkit-box-shadow: 0 0 27px #ff5c00; }
  to { background-color: #b84c04; -webkit-box-shadow: 0 0 9px #333; }
}

@-webkit-keyframes orangellowPulse {
  from { background-color: #bd5000; -webkit-box-shadow: 0 0 9px #333; }
  50% { background-color: #ffb515; -webkit-box-shadow: 0 0 27px #ffb515; }
  to { background-color: #bd5000; -webkit-box-shadow: 0 0 9px #333; }
}

a.button {
	-webkit-animation-duration: 2s;
	-webkit-animation-iteration-count: infinite; 
}
.green.button { -webkit-animation-name: greenPulse;animation-name: greenPulse; -webkit-animation-duration: 2s;animation-duration: 3s; }
.blue.button { -webkit-animation-name: bluePulse; -webkit-animation-duration: 4s; }
.red.button { -webkit-animation-name: redPulse; -webkit-animation-duration: 2s; }
.magenta.button { -webkit-animation-name: magentaPulse; -webkit-animation-duration: 3s; }
.orange.button { -webkit-animation-name: orangePulse; -webkit-animation-duration: 4s; }
.orangellow.button { -webkit-animation-name: orangellowPulse; -webkit-animation-duration: 2s; }
.button {-moz-border-radius: 5px; -webkit-border-radius: 5px; display: inline-block; padding: 1px 5px 2px; color: #fff !important; line-height: 1; text-decoration: none; -moz-box-shadow: 0 1px 3px rgba(0,0,0,0.25); -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.25); text-shadow: 0 -1px 1px rgba(0,0,0,0.25); border-bottom: 1px solid rgba(0,0,0,0.25); position: relative; cursor: pointer; overflow: visible; width: auto; }
button::-moz-focus-inner { border: 0; padding: 0; }
.button:hover { background-color: #111; color: #fff; }
.button:active { -webkit-transform: translateY(1px); -moz-transform: translateY(1px); }
.green.button { background-color: #91bd09; }
.green.button:hover { background-color: #749a02; }
.blue.button { background-color: #2daebf; }
.blue.button:hover { background-color: #007d9a; }
.red.button { background-color: #e33100; }
.red.button:hover { background-color: #872300; }
.magenta.button{ background-color: #a9014b; }
.magenta.button:hover { background-color: #630030; }
.orange.button { background-color: #ff5c00; }
.orange.button:hover { background-color: #d45500; }
.orangellow.button { background-color: #ffb515; }
.orangellow.button:hover { background-color: #fc9200; }
.white.button { background-color: #fff; border: 1px solid #ccc; color: #666 !important; font-weight: normal; text-shadow: 0 1px 1px rgba(255,255,255,1); }
.white.button:hover { background-color: #eee; }
/*外加标签样式结束*/

然后保存。

二、定位到wp-includes文件夹下category-template.php的wp_generate_tag_cloud()函数:

	//generate the output links array
	foreach ( $tags_data as $key => $tag_data ) {
		$a[] = "<a href='" . esc_url( $tag_data['url'] ) . "' class='" . esc_attr( $tag_data['class'] ) 
		. "' title='" . esc_attr( $tag_data['title'] ) . "' style='font-size: " 
		. esc_attr( str_replace( ',', '.', $tag_data['font_size'] ) . $args['unit'] ) 
		. ";'>" . esc_html( $tag_data['name'] ) . "</a>";
	}

将这段代码改为:

	//generate the output links array
	$color = array("green","blue","red","orange","orangellow");
	$i = 0;
	foreach ( $tags_data as $key => $tag_data ) {
	    $i = $i>=count($color)?0:$i;
		$a[] = "<a href='" . esc_url( $tag_data['url'] ) . "' class='" . esc_attr( $tag_data['class'] ) 
		." ".$color[$i]." button' title='" . esc_attr( $tag_data['title'] ) . "' style='font-size: " 
		. esc_attr( str_replace( ',', '.', $tag_data['font_size'] ) . $args['unit'] ) . ";'>" 
		. esc_html( $tag_data['name'] ) . "</a>";
		$i++;
	}

保存后,重新打开页面可以看到如下效果:

点击查看效果

 

发表评论?

4 条评论。

  1. background:url(/i/bg_flower.gif);
    background-size:100px 80px;/*更改长和高,可拉伸图片*/
    -moz-background-size:63px 100px; /* 老版本的 Firefox */
    background-repeat:no-repeat;

  2. background或background-color:transparent; 该参数为100%透明
    background-size:cover;把背景图像扩展至足够大,以使背景图像完全覆盖背景区域
    border-radius:5px;半径5px的圆角
    opacity:0.5;50%透明

  3. wp_generate_tag_cloud代码有问题,择日更改。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.