欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Javascript+CSS實現(xiàn)影像卷簾效果思路及代碼

 更新時間:2014年10月20日 16:59:20   投稿:whsnow  
Arcmap里面的一個卷簾效果肯定記憶很深刻,我也對這種比較炫的卷簾效果做了一下研究,現(xiàn)在給大家匯報下結(jié)果

用過Arcgis的筒子們對于Arcmap里面的一個卷簾效果肯定記憶很深刻,想把它搬到自己的WebGIS系統(tǒng)中去,抱著同樣的想法,我也對這種比較炫的卷簾效果做了一下研究,吼吼,出來了,給大家匯報一下成果

看到這樣的效果,你是不是小雞動了一下,嘿嘿,別急,聽我慢慢道來。

首先,容器。分別用兩個DIV來顯示兩個不同時期的影像。接下來設(shè)置兩個容器的樣式,代碼:

#after{ 
position: absolute; 
top: 0px; 
left: 0px; 
background-image: url(../images/24.jpg); 
width: 940px; 
height: 529px; 
background-repeat: no-repeat; 
} 
#before{ 
position: absolute; 
top: 0px; 
left: 0px; 
border-right: 3px solid #f00; 
background-image: url(../images/23.jpg); 
width: 433px; 
height: 529px; 
background-repeat: no-repeat; 
max-width: 940px; 
} 


這樣,圖片就在web上顯示出來了。


接下來實現(xiàn)卷簾效果。實現(xiàn)卷簾,最主要的是設(shè)置before的寬度,如何去設(shè)置呢,就是獲取鼠標的位置,代碼如下:

function RollImage(evt){ 
var x=evt.pageX; 
console.log(x); 
$("#before").css("width",x+"px"); 
} 
/script>

這樣,卷簾的效果就實現(xiàn)了。源代碼如下:

style.css

.beforeafter{ 
width: 940px; 
height: 529px; 
} 
#after{ 
position: absolute; 
top: 0px; 
left: 0px; 
background-image: url(../images/24.jpg); 
width: 940px; 
height: 529px; 
background-repeat: no-repeat; 
} 
#before{ 
position: absolute; 
top: 0px; 
left: 0px; 
border-right: 3px solid #f00; 
background-image: url(../images/23.jpg); 
width: 433px; 
height: 529px; 
background-repeat: no-repeat; 
max-width: 940px; 
} 

test.html


<html lang="zh-CN" xmlns="http://www.w3.org/1999/xhtml"><head> 
<title>日本地震災(zāi)區(qū)前后對比</title> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
<meta http-equiv="Content-Language" content="zh-CN"> 
<link href="css/roll.css" type="text/css" rel="stylesheet"> 
<script src="../jquery-1.8.3.js" type="text/javascript" charset="utf-8"></script> 
<script type="text/javascript"> 
function RollImage(evt){ 
<strong>var x=evt.pageX; 
$("#before").css("width",x+"px");</strong> 
} 
</script> 
</head> 
<body> 
<div class="beforeafter" onmousemove="RollImage(event)"> 
<div id="after"></div> 
<div id="before"> </div> 
</div> 
</body> 
</html> 

相關(guān)文章

最新評論