最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jquery實現(xiàn)移動端點擊圖片查看大圖特效

 更新時間:2020年09月11日 14:14:53   投稿:lijiao  
這篇文章主要介紹了jquery實現(xiàn)移動端點擊圖片查看大圖特效,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文的需求很簡單:點擊圖片查看大圖,再點大圖隱藏。多用于移動端,因為移動端屏幕小,可能需要查看大圖。

具體實現(xiàn)代碼

<!DOCTYPE html>
<html>
<meta charset="utf-8"/>
<head runat="server">
<title>JQuery點擊圖片查看大圖by starof</title>
<style type="text/css">
.exampleImg { height:100px; cursor:pointer;}
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
//alert($);
// (function (window, undefined) {
// var MyJQuery = function () {
// window.MyjQuery = window.$ = jQuery; window.$ = MyJQuery;
// };
// })(window);
// alert($);

$.fn.ImgZoomIn = function () {

bgstr = '<div id="ImgZoomInBG" style=" background:#000000; filter:Alpha(Opacity=70); opacity:0.7; position:fixed; left:0; top:0; z-index:10000; width:100%; height:100%; display:none;"><iframe src="about:blank" frameborder="5px" scrolling="yes" style="width:100%; height:100%;"></iframe></div>';
//alert($(this).attr('src'));
imgstr = '<img id="ImgZoomInImage" src="' + $(this).attr('src')+'" onclick=$(\'#ImgZoomInImage\').hide();$(\'#ImgZoomInBG\').hide(); style="cursor:pointer; display:none; position:absolute; z-index:10001;" />';
if ($('#ImgZoomInBG').length < 1) {
$('body').append(bgstr);
}
if ($('#ImgZoomInImage').length < 1) {
$('body').append(imgstr);
}
else {
$('#ImgZoomInImage').attr('src', $(this).attr('src'));
}
//alert($(window).scrollLeft());
//alert( $(window).scrollTop());
$('#ImgZoomInImage').css('left', $(window).scrollLeft() + ($(window).width() - $('#ImgZoomInImage').width()) / 2);
$('#ImgZoomInImage').css('top', $(window).scrollTop() + ($(window).height() - $('#ImgZoomInImage').height()) / 2);
$('#ImgZoomInBG').show();
$('#ImgZoomInImage').show();
};

$(document).ready(function () {
$("#imgTest").bind("click", function () {
$(this).ImgZoomIn();
});
});
</script>
</head>
<body>
<div>
<!--第一種寫法-->
<img class="exampleImg" src="images/03.jpg" id="imgTest"/>
<!--第二種寫法-->
<img class="exampleImg" src="images/p1_nav2.png" onClick="$(this).ImgZoomIn();"/>
</div>
</body>
</html>

jquery實現(xiàn)移動端點擊圖片查看大圖特效需要用到的技巧
需要點擊圖片中1、2、3、4四張小圖分別查看大圖,而下面左右按鈕切換時是需要同時切換4張小圖。


因為移動端無法添加熱點,最終一個解決方法是使用四個a標簽定位到左上角,右上角,左下角,右下角四個區(qū)域。

<dl>
  <dd style="display:block;">
   <img src="images/four-duche.jpg" onClick="$(this).ImgZoomIn();">
   <a href="javascript:;" src="images/11.jpg" class="topleft" onClick="$(this).ImgZoomIn();"></a>
   <a href="javascript:;" src="images/12.jpg" class="topright" onClick="$(this).ImgZoomIn();"></a>
   <a href="javascript:;" src="images/13.jpg" class="bottomleft" onClick="$(this).ImgZoomIn();"></a>
   <a href="javascript:;" src="images/14.jpg" class="bottomright" onClick="$(this).ImgZoomIn();"></a>
 </dd>
 ...
</dl>

css

.topleft,.topright,.bottomleft,.bottomright{
 width:50%;
 height:50%;
 position:absolute;
}

.topleft{
 /*background-color:red;*/
 top:0;
 left:0;
}
.topright{
 /*background-color:green;*/
 top:0;
 right:0;
}
.bottomleft{
 /*background-color:blue;*/
 bottom:0;
 left:0;
}
.bottomright{
 /*background-color:yellow;*/
 bottom:0;
 right:0;
}

以上就是移動端點擊圖片查看大圖的實現(xiàn)過程,希望對大家的學習有所幫助。

相關文章

最新評論

沛县| 临澧县| 称多县| 淮滨县| 黔东| 藁城市| 合肥市| 吴川市| 右玉县| 万安县| 墨江| 祁连县| 垣曲县| 长治市| 河津市| 靖边县| 陇川县| 疏勒县| 永寿县| 宾阳县| 威海市| 突泉县| 马山县| 新巴尔虎右旗| 西峡县| 长子县| 娄底市| 应用必备| 永德县| 株洲市| 阜康市| 黄山市| 柳州市| 南华县| 阿克| 即墨市| 雅安市| 西城区| 双牌县| 会同县| 商水县|