var div = $("div");
創(chuàng)新互聯(lián)公司長(zhǎng)期為千余家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺(tái),與合作伙伴共同營(yíng)造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為鄂州企業(yè)提供專業(yè)的網(wǎng)站制作、網(wǎng)站建設(shè),鄂州網(wǎng)站改版等技術(shù)服務(wù)。擁有十年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開發(fā)。
div.css("lfet",value);
div.css("top",value)
....同理
div.width(200) // 同樣也可以用上述css方式來(lái)實(shí)現(xiàn)。 div.css("width",value); height跟width一樣。
今天要出個(gè)鼠標(biāo)滾動(dòng)放大縮小圖片的功能,看似很簡(jiǎn)單,從網(wǎng)上一搜,出現(xiàn)的都是onmousewheel的例子,全部只支持IE瀏覽器,結(jié)果查出火狐有對(duì)應(yīng)的DOMMouseScroll來(lái)處理這個(gè)功能,代碼如下,并加上注意的注釋項(xiàng):
復(fù)制代碼
代碼如下:
$(function(){
$(".body
img").each(function(){
if($.browser.msie){
$(this).bind("mousewheel",function(e){
var
e=e||event,v=e.wheelDelta||e.detail;
if(v0)
resizeImg(this,false);//放大圖片唄
else
resizeImg(this,true);//縮小圖片嘍
window.event.returnValue
=
false;//去掉瀏覽器默認(rèn)滾動(dòng)事件
//e.stopPropagation();
return
false;
})
}else{
$(this).bind("DOMMouseScroll",function(event){
if(event.detail0)
resizeImg(this,false);
else
resizeImg(this,true);
event.preventDefault()//去掉瀏覽器默認(rèn)滾動(dòng)事件
//event.stopPropagation();
})
}
});
function
resizeImg(node,isSmall){
if(!isSmall){
$(node).height($(node).height()*1.2);
}else
{
$(node).height($(node).height()*0.8);
}
}
});
本文的demo請(qǐng)點(diǎn)擊這里:滾動(dòng)鼠標(biāo)放大縮小圖片效果
!doctype?html
html
head
titlejquery-ui/title
meta?html-equiv="content-type"?content="text/html,charset=utf-8"/meta
/head
link?rel="stylesheet"?href="
link?rel="stylesheet"?type="text/css"?href="css/nav.css"
script
$(function(){
??$("#menu").menu();??????????!---菜單樣式--
??$("#menu"?).draggable();???!---可拖動(dòng)--
??$("#menu").resizable();????!--放大/縮小--
??$("#tabs").tabs();
??$("#accordion").accordion();
???$(?"#sortable"?).sortable();??!--排序--
$(?"#sortable"?).disableSelection();
});
/script
style
body{
width:90%;
background:url(image/bg0.jpg);
margin:0?auto;
}
.ui-menu?{
???width:100px;
???text-align:center;
???margin:0?auto;
}
.ui-tabs{
?border:1px?solid?green;
}
#accordion{
??width:100%;
??height:200px;
}
.content{
?height:1000px;
?width:100%;
?border:5px?solid?#87CEFA;
?-moz-border-radius:?15px;
-webkit-border-radius:?15px;
border-radius:15px;
}
.cdown{?
???margin:0?auto;
???width:100%;
}
.ctop{
?margin:0?auto;
??width:100%;
???height:500px;
}
#tabs-1{
??background:url(image/p-bg1.jpg)?no-repeat;
}
#tabs-2{
??background:url(image/p-bg2.jpg)?no-repeat;
}
#tabs-3{
??background:url(image/p-bg3.jpg)?no-repeat;
}?
#tabs?ul?li{
background:#76EEC6;
}
?
.c{
??height:250px;
}
#sortable?image{
??width:155px;
margin-left:10px;
}
/style
body
nav
ul
lia?href="#"?首頁(yè)/a/li
lia?href="#"?第一/a/li
???lia?href="#"?第二/a/li
???lia?href="#"?第三/a/li
???lia?href="#"?第四/a/li
???lia?href="#"?關(guān)于我們/a/li
/ul
/nav
div?class="content"
div?class="ctop"
div?id="accordion"
h3圖片可重新排序/h3
div?class="c"?id="sortable"image?src="image/pic1.jpg"/image?src="image/pic2.jpg"/image?src="image/pic3.jpg"/image?src="image/pic4.jpg"/image?src="image/pic5.jpg"http://div
h3Second/h3
div?class="c"Second?Second?Second?Second?Second?Second?Second?Second?Second?Second?Second/div
h3Third/h3
div?class="c"Third?Third?Third?Third?Third?Third?Third?Third?Third?Third?Third?Third?Third/div
/div
/div
div?class="cdown"
???div?id="tabs"
ul
lia?href="#tabs-1"?class="one"First/a/li
lia?href="#tabs-2"?Second/a/li
lia?href="#tabs-3"?Third/a/li
/ul
div?id="tabs-1"?class="c"First?First?First?First?First?First?First?First?First?First?First?First?First/div
div?id="tabs-2"?class="c"Second?Second?Second?Second?Second?Second?Second?Second?Second?Second?Second/div
div?id="tabs-3"?class="c"Third?Third?Third?Third?Third?Third?Third?Third?Third?Third?Third?Third?Third/div
/div
/div
/div
ul?id="menu"?class="ui-widget-content"
li?class="ui-state-disabled"?style="font-size:10px;text-align:center"菜單(可拖動(dòng))/li
lia?href="#"abcd/a
???ul
?lia?href="#"aaa/a/li
?lia?href="#"bbb/a/li
?lia?href="#"ccc/a/li
?lia?href="#"ddd/a/li
???/ul
?/li
??lia?href="#"efg/a
???ul
?lia?href="#"eee/a/li
?lia?href="#"fff/a/li
?lia?href="#"ggg/a/li
???/ul
?/li
/ul
/div
/body
/html