• 博客設置
  • 編輯管理
  • 返回首頁
焚花祭秋
Wordpress Typecho 以及周邊知識的一個筆記,成長的過程中相互學習,共同進步!
首頁 歸檔 關於 友鏈 留言
分類
  • 博客.技巧
  • 網絡.主機
  • HOME
  • 博客.技巧
  • WordPress,側欄等地方非插件實現Tab切換的效果代碼分享

WordPress,側欄等地方非插件實現Tab切換的效果代碼分享

作者:焚花祭秋  /   发布时间:November 2, 2011  /   分类:博客.技巧  /   1 Comment

字體大小選擇: [ 超大字體 中型字體 默認字體 ]

這個貌似用到的博客挺多的,像我的博客就有用到了這種效果,好處是比較省地方,側欄太長影響和諧啊,這個東西還挺不錯的,其實實現起來挺簡單的,下面來說下代碼實現這種效果的方法,供大家參考下!

首先鳴謝下Iecho同學,希望大家多多分享,多多支持啊!

其實這個不僅可以用於側欄,底欄,頭部都沒有問題的,只需要稍微調整下格式即可,下面通過示例說下實現的方法!

首先:在需要他顯示的地方加入以下代碼,如下:

1
2
3
4
5
6
7
8
<div class="widget_tabcontent">
<h3><span class="selected">最新文章</span> 
<span>最熱文章</span> 
<span>隨機文章</span></h3>
<ul>插入要調用的函數</ul>
<ul class="hide">插入要調用的函數</ul>
<ul class="hide">插入要調用的函數</ul>
</div>

其次:引入加載JS文件,這個挺小的,直接貼代碼,適當的位置調用即可,代碼如下:

1
2
3
4
5
6
7
8
9
10
<script type="text/javascript">
 jQuery(document).ready(function($){ 
 //註意要用這個把jQuery代碼都包裹起來,不然裏面的可都是無效的哦~
$('.widget_tabcontent h3 span').click(function(){
    $(this).addClass("selected").siblings().removeClass();
    $(".widget_tabcontent > ul").slideUp('1500').eq($('.widget_tabcontent h3 
span').index(this)).slideDown('1500');
});
});
</script>

註意:默認的是點擊切換特效,如果喜歡,也可以改成鼠標移動指向自動切換的,將click(function()中的click改成mouseover即可,顯示方式修改slideUp/slideDown即可!

最後,又是老生常談的並且讓人頭疼的CSS樣式,提供一小段,自己參詳吧!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
.widget_tabcontent h3 span
{
	cursor:pointer;
	padding-bottom:4px;
}
.widget_tabcontent h3 span:hover
{
	color:#D54E21;
}
.selected
{
	color:#D54E21;
	border-bottom:1px solid #D54E21;
}
/*標題被選中時的樣式*/
	.widget_tabcontent .hide
{
	display:none;
}
/*默認讓第一塊內容顯示,其余隱藏*/
	.widget_tabcontent ul li:hover
{
	background-color:#EEE;
	border-radius:5px;
	-webkit-border-radius:5px;
	-moz-border-radius:5px;
	-khtml-border-radius:5px;
	cursor:pointer;
}

下面給出一些常用的調用文章代碼,大家可以根據需要插入到適當的位置就好了:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
熱門文章:
<?php query_posts(array('posts_per_page' => 10,
'caller_get_posts' =>1,'orderby' =>comment_count,)); 
while ( have_posts() ) : the_post(); ?>
<li><a href="<?php the_permalink() ?>" rel="bookmark" 
title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
<?php endwhile;wp_reset_query();?>
 
最新文章:
<?php query_posts(array('posts_per_page' => 10,
'caller_get_posts' =>1,'orderby' =>date,));
while ( have_posts() ) : the_post(); ?>
<li><a href="<?php the_permalink() ?>" rel="bookmark" 
title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
<?php endwhile;wp_reset_query();?>
 
隨機文章:
<?php query_posts(array('posts_per_page' => 10,
'caller_get_posts' =>1,'orderby' =>rand,)); 
while ( have_posts() ) : the_post(); ?>
<li><a href="<?php the_permalink() ?>" rel="bookmark" 
title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
<?php endwhile;wp_reset_query();?>

更多想點擊下面的文章詳細查看!

Shall We Go!下面GO GO GO!

L—>No1.WordPress,免插件文章輸出代碼分享之最新發布文章

L—>No2.WordPress,免插件文章輸出代碼分享之最多評論頁面和文章

L—>No3.WordPress,免插件文章輸出代碼分享之隨機文章推薦

L—>No4.WordPress,免插件文章輸出代碼分享之隨機點擊進入一篇文章


Ovoer!基本就是這樣,休息一下,馬上回來!

上一篇: WordPress,非插件實現返回頂部,底部,留言的代碼分享 下一篇: WordPress,登陸博客郵件提醒的代碼分享
    分享到: QQ空間 新浪微博 騰訊微博 開心網 人人網 淘江湖 百度空間
訂閱本站:焚花祭秋
文本標籤:wordpress側欄tab, wordpress3和1tab
友情聲明:本站所有文章皆為原創,圖文皆為網絡搜索傳播,轉載請以鏈接形式標明原文出處地址,謝謝合作!
本文鏈接:http://tc.muo.me/wordpress-other-sidebar-tab-to-switch-to-local-non-plug-ins-to-achieve-effects-of-code-sharing.html [复制]
My WeChat

簡繁切換

    • Wordpress,非插件實現評論者回復插入圖片功能代碼分享
    • WordPress 留言板添加Ctrl+Enter 快捷回復
    • LinuxVPS CentOS Debian Ubuntu Shadowsocks 一鍵安裝腳本教程
    • WordPress 獲取顯示文章內圖片作為縮略圖的方法
    • 網站網頁上面添加字體大小控制的代碼實現方法
    • ASS和SRT等影視外掛字幕之間的相互轉化 低級篇

  • YueTing.Org
    悦听有声,路过看看
  • 自由草
    简繁转换功能在也没刷新下会失效
  • 天地华宇
    好东西 谢谢分享先收藏一下下 ...
  • flippy
    主题蛮好看的,好像轻博客一样
  • flippy
    不错呀
  • qkwu
    不错哦 收藏了
文章 RSS And 评论 RSS
焚花祭秋 Is Powered By Wordpress Theme Desgin By 沫(Muo.me)