jquery toolbar與網(wǎng)頁(yè)浮動(dòng)工具條具體實(shí)現(xiàn)代碼
/*
基本StructureWe'll更新index.php教程的HTML代碼和對(duì)新聞聯(lián)播style.css教程中的CSS代碼。
我們建立了一個(gè)固定的面板(ID為工具欄組)兩個(gè)浮動(dòng)方面,我們將在第二個(gè)步驟與他們的圖標(biāo)和提示氣泡(左),一個(gè)快速菜單和“隱藏按鈕列表”(添加到隱藏工具欄)。
我們還可以期待一個(gè)“顯示按鈕”,它是有用的,當(dāng)面板隱藏,我們要重新激活它?;谶@個(gè)原因,我們添加id為toolbarbut div標(biāo)簽。
HTML和CSS代碼
在這里,網(wǎng)頁(yè)的基本結(jié)構(gòu)。
html 代碼
<div id=”toolbarbut”>
<!– hide button –>
</div>
<div id=”toolbar”> <!– toolbar container –>
<div class=”leftside”>
<!– all icons in floating left side –>
</div>
<div class=”rightside”> <!– all things in floating right side –>
<!– hide button –>
<!– quick menu list –>
</div>
</div>
css代碼
div#toolbar, div#toolbarbut {
position: fixed; /* set fixed position for the bar */
bottom: 0px;
right: 0px;
z-index: 9999; /* keep the bar on top */
height: 36px;
background: url(images/bcktool.png);
/* CSS3 */
-moz-border-radius-topleft: 8px;
-khtml-border-radius-topleft: 8px;
-webkit-border-top-left-radius: 8px;
-moz-border-radius-topright: 8px;
-khtml-border-radius-topright: 8px;
-webkit-border-top-right-radius: 8px;
-moz-box-shadow: 0px 1px 10px #666, inset 1px 1px 0px #a4a4a4; /* inset creates a inner-shadow */
-khtml-box-shadow: 0px 1px 10px #666;
-webkit-box-shadow: 0px 1px 10px #666;
/* CSS3 end */
border-top: 1px solid #eee;
border-left: 1px solid #eee;
border-right: 1px solid #eee;
}
div#toolbar {
width: 85%;
min-width: 700px; /* to limit the width when there is an excessive window resize */
margin: 0px auto; /* centered toolbar */
left: 0px;
}
div#toolbar a:hover {
border: none; /* fix ‘hover' (a:hover {border-bottom: 1px dotted #666;}) border in the News Aggregator */
}
div#toolbarbut { /* div for the ‘hide status' */
width: 60px;
height: 15px;
margin-right: 3%;
display: none;
}
.leftside {
float: left;
}
.rightside {
float: right;
}
顯示/隱藏按鈕現(xiàn)在,我們可以添加“顯示按鈕”的代碼。
<div id=”toolbarbut”> <!– hide button –>
<span class=”showbar”><a href=”#”>show bar</a></span>
</div>
下面的屬性相對(duì)CSS類。
span.showbar a { /* show button */
padding: 5px;
font-size: 10px;
color: #989898;
}
我們完成了后來(lái)的右側(cè),但現(xiàn)在我們可以添加“隱藏按鈕”在ID為rightside分區(qū),如圖所示。
<div class=”rightside”>
<span class=”downarr”> <!– hide button –>
<a href=”#”></a>
</span>
<!– other stuff in floating right side –>
</div>
css
span.downarr { /* hide button */
float: right;
border-left: 1px solid #a4a4a4;
}
span.downarr a {
display: block;
width: 36px;
height: 26px;
padding: 25px 0 0 10px;
background: url(images/downarrow.png) no-repeat 5px 7px;
}
顯示/隱藏效果與jQuery首先我們需要下載的jQuery(復(fù)制正確的文件夾中),并激活頭index.php的標(biāo)記。
<head>
<!– … –>
<script type=”text/javascript教程” src=”js/jquery-1.3.2.min.js”></script>
</head>
我們要隱藏面板上“隱藏按鈕”,點(diǎn)擊工具欄時(shí),應(yīng)當(dāng)有不可見(jiàn)的“顯示按鈕”,使我們能夠恢復(fù)的面板。我們可以使用下面的jQuery的解決方案(<body>標(biāo)記后添加的代碼)。
<script type=”text/javascript”>
$(document).ready(function(){
//hide toolbar and make visible the ‘show' button
$(“span.downarr a”).click(function() {
$(“#toolbar”).slideToggle(“fast”);
$(“#toolbarbut”).fadeIn(“slow”);
});
//show toolbar and hide the ‘show' button
$(“span.showbar a”).click(function() {
$(“#toolbar”).slideToggle(“fast”);
$(“#toolbarbut”).fadeOut();
});
});
</script>
現(xiàn)在我們可以隱藏和顯示的bar
HTML和CSS代碼的左側(cè)
更新索引用下面的XHTML代碼。我們添加一個(gè)普通無(wú)序列表(ID為社會(huì))來(lái)創(chuàng)建的圖標(biāo)順序,一個(gè)DIV標(biāo)簽(與類一角)范圍內(nèi)的總表,以實(shí)現(xiàn)工具提示氣泡里的標(biāo)簽嵌套。
html
<div class=”leftside”> <!– all things in floating left side –>
<ul id=”social”>
<li><a class=”rss” href=”#”></a><!– icon –>
<div id=”tiprss” class=”tip”><!– tooltip –>
<ul>
<li><a href=”#”>580 Readers</a></li>
<li><a href=”#”><small>[Subscribe]</small></a></li>
</ul>
</div>
</li>
<li><a class=”facebook” href=”#”></a>
<div id=”tipfacebook” class=”tip”>
<ul>
<li><a href=”#”>Share Page</a></li>
<li><a href=”#”>| Profile</a></li>
</ul>
</div>
</li>
<li><a class=”twitter” href=”#”></a>
<div id=”tiptwitter” class=”tip”>
<ul>
<li><a href=”#”>ReTweet</a></li>
<li><a href=”#”>| Profile</a></li>
</ul>
</div>
</li>
<li><a class=”delicious” href=”#”></a>
<div id=”tipdelicious” class=”tip”>
<ul>
<li><a href=”#”>Bookmark</a></li>
<li><a href=”#”>| Profile</a></li>
</ul>
</div>
</li>
<li><a class=”digg” href=”#”></a>
<div id=”tipdigg” class=”tip”>
<ul>
<li><a href=”#”>Digg</a></li>
<li><a href=”#”>| Profile</a></li>
</ul>
</div>
</li>
<li><a class=”stumble” href=”#”></a>
<div id=”tips教程tumble” class=”tip”>
<ul>
<li><a href=”#”>Stumble</a></li>
<li><a href=”#”>| Profile</a></li>
</ul>
</div>
</li>
</ul>
</div>
css代碼
*– Left Side –*/
ul#social li {
display: inline;
}
a.rss {
display: inline-block;
width: 104px;
height: 35px;
margin-left: 5px;
background: url(images/rss.png) no-repeat;
}
a.facebook, a.twitter, a.digg, a.delicious, a.stumble {
display: inline-block;
width: 40px;
height: 35px;
margin-top: 1px;
}
a.rss:hover, a.facebook:hover, a.twitter:hover, a.digg:hover, a.delicious:hover, a.stumble:hover {
background-position: 1px 1px; /* simple css hover effect */
}
a.facebook {
background: url(images/facebook.png) no-repeat;
}
a.twitter {
background: url(images/twitter.png) no-repeat;
}
a.delicious {
background: url(images/delicious.png) no-repeat;
}
a.digg {
background: url(images/digg.png) no-repeat;
}
a.stumble {
background: url(images/stumble.png) no-repeat;
}
.tip {
position: absolute; /* important */
top: -75px;
width: 250px;
height: 78px;
background: url(images/tip.png) no-repeat;
float: left;
display: none;
}
/* custom distances for the icons */
#tipfacebook {
left: 75px;
}
#tiptwitter {
left: 120px;
}
#tipdelicious {
left: 165px;
}
#tipdigg {
left: 210px;
}
#tipstumble {
left: 255px;
}
.tip ul {
padding: 22px 0 0 25px;
}
.tip ul li {
display: inline;
padding-left: 3px;
}
.tip ul li a {
font-size: 18px;
color: #989898;
}
.tip ul li a:hover {
color: #666;
}
.tip ul li small {
font-size: 10px;
}
jquery代碼
//show tooltip when the mouse is moved over a list element
$(“ul#social li”).hover(function() {
$(this).find(“div”).fadeIn(“fast”).show(); //add ‘show()” for IE
$(this).mouseleave(function () { //hide tooltip when the mouse moves off of the element
$(this).find(“div”).hide();
});
});
OK好了,我們的jquery 實(shí)現(xiàn)toolbar與網(wǎng)頁(yè)浮動(dòng)工具條jQuery實(shí)現(xiàn)方法就講完了。
?>
- 微軟IE Developer Toolbar安裝使用簡(jiǎn)要圖文說(shuō)明
- Java Swing中的工具欄(JToolBar)和分割面版(JSplitPane)組件使用案例
- Toolbar制作菜單條過(guò)程詳解
- iOS應(yīng)用中使用Toolbar工具欄方式切換視圖的方法詳解
- iOS中的導(dǎo)航欄UINavigationBar與工具欄UIToolBar要點(diǎn)解析
- Android5.0+ CollapsingToolbarLayout使用詳解
- Android自定義ActionProvider ToolBar實(shí)現(xiàn)Menu小紅點(diǎn)
- Android自定義Toolbar使用方法詳解
- 分別用ToolBar和自定義導(dǎo)航欄實(shí)現(xiàn)沉浸式狀態(tài)欄
- 深入理解Android 5.0中的Toolbar
相關(guān)文章
jquery.validate.js插件使用經(jīng)驗(yàn)記錄
工作中使用到了jquery.validate.js插件,下面將其用法整理一下,方便以后使用2014-07-07
jquery實(shí)現(xiàn)九宮格大轉(zhuǎn)盤(pán)抽獎(jiǎng)
jQuery九宮格大轉(zhuǎn)盤(pán)抽獎(jiǎng)代碼網(wǎng)頁(yè)特效,點(diǎn)擊抽獎(jiǎng)按鈕開(kāi)始隨機(jī)抽獎(jiǎng)選擇獎(jiǎng)品,可設(shè)置起點(diǎn)位置、獎(jiǎng)品數(shù)量、轉(zhuǎn)動(dòng)次數(shù)、中獎(jiǎng)位置參數(shù)2015-11-11
分享十五款 jQuery 社交網(wǎng)絡(luò)分享插件
這篇文章主要介紹了分享十五款 jQuery 社交網(wǎng)絡(luò)分享插件,需要的朋友可以參考下2015-05-05
jQuery可見(jiàn)性過(guò)濾器:hidden和:visibility用法實(shí)例
這篇文章主要介紹了jQuery可見(jiàn)性過(guò)濾器:hidden和:visibility用法,實(shí)例分析了:hidden和:visibility的功能及相關(guān)使用技巧,需要的朋友可以參考下2015-06-06
jquery easyui 結(jié)合jsp簡(jiǎn)單展現(xiàn)table數(shù)據(jù)示例
這篇文章主要介紹了jquery easyui 結(jié)合jsp簡(jiǎn)單展現(xiàn)table數(shù)據(jù),需要的朋友可以參考下2014-04-04
jQuery基礎(chǔ)知識(shí)點(diǎn)總結(jié)(必看)
下面小編就為大家?guī)?lái)一篇jQuery基礎(chǔ)知識(shí)點(diǎn)總結(jié)(必看)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-05-05
8個(gè)超棒的學(xué)習(xí) jQuery 的網(wǎng)站 推薦收藏
根據(jù)國(guó)外科技網(wǎng)站 W3Techs 一項(xiàng)調(diào)查了近100萬(wàn)個(gè)網(wǎng)站數(shù)據(jù)顯示,jQuery是目前最流行的 JavaScript 庫(kù)。2011-04-04
JQuery 動(dòng)畫(huà)卷頁(yè) 返回頂部 動(dòng)畫(huà)特效(兼容Chrome)
JQuery 動(dòng)畫(huà)卷頁(yè) 返回頂部 動(dòng)畫(huà)特效(兼容Chrome) ,學(xué)習(xí)jquery的朋友可以測(cè)試下。2010-02-02

