用jquery 給圖片添加css樣式,用css樣式來控制旋轉(zhuǎn):

成都創(chuàng)新互聯(lián)公司專注于銅川企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站開發(fā),商城網(wǎng)站建設(shè)。銅川網(wǎng)站建設(shè)公司,為銅川等地區(qū)提供建站服務(wù)。全流程按需求定制制作,專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,成都創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務(wù)
CSS3 transform 屬性
transform具體的用法去百度吧 ,手冊里解釋很全面
大致原理如下:
//初始化界面
var itemList, item, className, thisItem, newOrder, itemDesc, desc;
itemList = $('#itemlist');
item = itemList.children('img');
itemDesc = $('#itemdescription');
desc = itemDesc.children('span');
//為每個項(xiàng)目添加類名稱
item.each(function(index) {
className = 'item-' + index;
$(this).addClass(className).attr('data-order', index);
});
//顯示第一個項(xiàng)目描述
desc.filter(':first-child').fadeIn();
//在點(diǎn)擊時激活動畫
item.on('click', function() {
thisItem = $(this);
thisOrder = parseInt(thisItem.attr('data-order')) - 1;
thisItem.addClass('show');
//重排項(xiàng)的位置
item.on('animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd', function() {
thisItem.removeClass().addClass('item-0').attr('data-order', '0');
//顯示選定的項(xiàng)目描述
desc.hide();
desc.filter('[data-for=' + thisItem.attr('id') + ']' ).fadeIn('fast');
});
//兄弟項(xiàng)目向后移動
window.setTimeout(function () {
for(var i = thisOrder; i = 0; i--) {
//重排項(xiàng)位置
movedItem = item.filter('[data-order=' + i + ']');
newOrder = parseInt(movedItem.attr('data-order')) + 1;
className = 'item-' + newOrder;
//動態(tài)過渡
movedItem.removeClass().addClass('transition ' + className).attr('data-order', newOrder);
//刪除他們的過渡
item.on('transitionend webkitTransitionEnd MSTransitionEnd oTransitionEnd', function() {
item.removeClass('transition');
});
}
}, 500);
});
});
如果你希望它更智能,那么你就需要多下點(diǎn)功夫了。其實(shí),道理都是一樣的,只不過做成什么樣的效果更好看而已。
本文實(shí)例講述了jQuery圖片旋轉(zhuǎn)插件jQueryRotate.js用法。分享給大家供大家參考,具體如下:
推薦一個圖片旋轉(zhuǎn)插件,用于瀏覽相冊時,旋轉(zhuǎn)圖片。
運(yùn)行效果截圖如下:
點(diǎn)擊此處查看在線演示效果。
具體代碼如下:
script
type="text/javascript"
$(document).ready(function
()
{
$("#images").rotate(45);
var
value
=
$("#images1").rotate({
bind:
{
mouseover:
function(){
value
+=90;
$(this).rotate({
animateTo:value})
}
}
});
$('#button').click(function(){
$("#images1").rotate({animateTo:parseInt($('#angel').val())});
});
function
rotation
(){
$("#images2").rotate({
angle:0,
animateTo:360,
callback:
rotation,
easing:
function
(x,t,b,c,d){
return
c*(t/d)+b;
}
});
}
rotation();
});
/script
上面只是js代碼,完整實(shí)例代碼點(diǎn)擊此處本站下載。
更多關(guān)于jQuery插件相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery常用插件及用法總結(jié)》
希望本文所述對大家jQuery程序設(shè)計(jì)有所幫助。
新聞標(biāo)題:jquery圖片翻轉(zhuǎn),jquery圖片切換
本文鏈接:http://chinadenli.net/article3/dsiggos.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航、小程序開發(fā)、網(wǎng)頁設(shè)計(jì)公司、靜態(tài)網(wǎng)站、網(wǎng)站制作、域名注冊
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)