欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

jquery頁面效果,jquery 效果

jQuery實現(xiàn)切換頁面過渡動畫效果

直接為大家介紹制作過程,希望大家可以喜歡。

在茂名等地區(qū),都構建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產品創(chuàng)新能力,以專注、極致的服務理念,為客戶提供成都網站設計、成都網站制作、外貿網站建設 網站設計制作定制設計,公司網站建設,企業(yè)網站建設,成都品牌網站建設,成都全網營銷,外貿網站建設,茂名網站建設費用合理。

HTML結構

該頁面切換特效的HTML結構使用一個main元素來作為頁面的包裹元素,div.cd-cover-layer用于制作頁面切換時的遮罩層,div.cd-loading-bar是進行ajax加載時的loading進度條。

main

div

class="cd-index

cd-main-content"

div

h1Page

Transition/h1

!--

your

content

here

--

/div

/div

/main

div

class="cd-cover-layer"/div

!--

this

is

the

cover

layer

--

div

class="cd-loading-bar"/div

!--

this

is

the

loading

bar

--

CSS樣式

該頁面切換特效中使用body::before和body::after偽元素在頁面切換過程中創(chuàng)建兩個遮罩層來遮住頁面內容。它們的定位是固定定位,高度等于50vh,寬度為100%。默認情況下,使用CSS

transform屬性將它們隱藏起來(translateY(-100%)/translateY(100%))。當用戶切換頁面的時候,這些元素被移動回視口當中(通過在body元素上添加.page-is-changing

class)。

下面的圖片演示了這個過程:

頁面切換特效

body::after,

body::before

{

/*

these

are

the

2

half

blocks

which

cover

the

content

once

the

animation

is

triggered

*/

height:

50vh;

width:

100%;

position:

fixed;

left:

0;

}

body::before

{

top:

0;

transform:

translateY(-100%);

}

body::after

{

bottom:

0;

transform:

translateY(100%);

}

body.page-is-changing::after,

body.page-is-changing::before

{

transform:

translateY(0);

}

頁面切換時,頁面內容的淡入淡出效果是通過改變div.cd-cover-layer的透明度實現(xiàn)的。它覆蓋了.cd-main-content元素,并具有相同的背景色,然后在body被添加.page-is-changing

class的時候,將透明度從0修改為1。

Loading進度條使用.cd-loading-bar::before偽元素來制作。默認它被縮小(scaleX(0))和transform-origin:

left

center。當頁面切換開始時它被使用scaleX(1)放大會原來的尺寸。

.cd-loading-bar

{

/*

this

is

the

loading

bar

-

visible

while

switching

from

one

page

to

the

following

one

*/

position:

fixed;

height:

2px;

width:

90%;

}

.cd-loading-bar::before

{

/*

this

is

the

progress

bar

inside

the

loading

bar

*/

position:

absolute;

left:

0;

top:

0;

height:

100%;

width:

100%;

transform:

scaleX(0);

transform-origin:

left

center;

}

.page-is-changing

.cd-loading-bar::before

{

transform:

scaleX(1);

}

特效中平滑的過渡效果使用CSS

Transitions來實現(xiàn)。每一個動畫元素都被添加了不同的transition-delay,以實現(xiàn)不同的元素動畫順序。

JAVASCRIPT

該頁面切換特效中在鏈接上使用data-type="page-transition"屬性,用于觸發(fā)頁面切換事件。當插件檢測到用戶點擊事件,changePage()方法將被執(zhí)行。

$('main').on('click',

'[data-type="page-transition"]',

function(event){

event.preventDefault();

//detect

which

page

has

been

selected

var

newPage

=

$(this).attr('href');

//if

the

page

is

not

animating

-

trigger

animation

if(

!isAnimating

)

changePage(newPage,

true);

});

這個方法會觸發(fā)頁面切換動畫,并通過loadNewContent()方法加載新內容。

function

changePage(url,

bool)

{

isAnimating

=

true;

//

trigger

page

animation

$('body').addClass('page-is-changing');

//...

loadNewContent(url,

bool);

//...

}

當新的內容被加載后,會替代原來main元素中的內容。.page-is-changing

class被從body中移除,新加載的內容會被添加到window.history中(使用pushState()方法)。

function

loadNewContent(url,

bool)

{

var

newSectionName

=

'cd-'+url.replace('.html',

''),

section

=

$('div

class="cd-main-content

'+newSectionName+'"/div');

section.load(url+'

.cd-main-content

*',

function(event){

//

load

new

content

and

replace

main

content

with

the

new

one

$('main').html(section);

//...

$('body').removeClass('page-is-changing');

//...

if(url

!=

window.location){

//add

the

new

page

to

the

window.history

window.history.pushState({path:

url},'',url);

}

});

}

為了在用戶點擊瀏覽器的回退按鈕時觸發(fā)相同的頁面切換動畫效果,插件中監(jiān)聽popstate事件,并在它觸發(fā)時執(zhí)行changePage()函數(shù)。

$(window).on('popstate',

function()

{

var

newPageArray

=

location.pathname.split('/'),

//this

is

the

url

of

the

page

to

be

loaded

newPage

=

newPageArray[newPageArray.length

-

1];

if(

!isAnimating

)

changePage(newPage);

});

在jquery中,怎樣實現(xiàn)刷新頁面的效果?

不需要使用jquery,使用javascript的setTimeout()即可實現(xiàn):

window.onload?=?function(){

setTimeout("location.reload()",2000);

}

代碼效果如下:

如何讓jquery動畫效果在屏幕滾動到指定位置才執(zhí)行

1、新建一個html文件,命名為test.html。

2、在test.html文件內,使用div標簽創(chuàng)建一個模塊,并設置其id為mycss。

3、在css標簽內,定義div的樣式,設置其寬度為100px,高度為2000px,背景顏色為粉紅色。

4、在js標簽內,使用scroll()方法監(jiān)聽頁面的滾動條,并執(zhí)行function方法。

5、在function方法內,使用if語句判斷,當前滾動的位置(scrollTop())是否到達頁面的底部($(document).height()-$(window).height()),如果到達頁面底部,提示“已經到底部了”。

新聞標題:jquery頁面效果,jquery 效果
標題URL:http://chinadenli.net/article30/phesso.html

成都網站建設公司_創(chuàng)新互聯(lián),為您提供外貿網站建設企業(yè)網站制作自適應網站網站營銷標簽優(yōu)化定制開發(fā)

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

外貿網站制作