Posted in jQuery onJuly 18, 2019
一、需求说明
效果如图:
二、代码实现
项目结构如图:
example.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>LIGHTBOX EXAMPLE</title> <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.js" ></script> <script type="text/javascript" src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script> <script type="text/javascript" src="js/jquery-mousewheel.js" ></script> <script type="text/javascript" src="js/mylightbox.js" ></script> <script type="text/javascript"> $(function(){ // 写法一: /*LightBox.init({ imgObj : $(".imgPreview"), config : { boxHeight : 300, boxWidth : 500 } });*/ // 写法二: $(".imgPreview").lightbox({ boxHeight : 300, boxWidth : 500 }); }); </script> <link rel="stylesheet" href="css/mylightbox.css" rel="external nofollow" /> <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" /> </head> <body> <img id="lightImgaa" class="imgPreview" src="images/1.png"/> <img id="lightImgbb" class="imgPreview" src="images/2.png"/> </body> </html>
mylightbox.css
.white_content { display: none; position: absolute; width: 800px; height: 600px; /*padding: 6px 16px;*/ padding: 0; border: 3px solid rgb(252,252,252, 0.2); background-color: #f5f6f7; z-index:1002; overflow: hidden; } .white_content .con { width: 800px; height: 600px; } .black_overlay { display: none; position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color:#777777; z-index:1001; -moz-opacity: 0.8; opacity:.80; filter: alpha(opacity=80); } .white_content .close { position: relative; float:right; clear:both; width:100%; text-align:right; margin:0; z-index: 10; height: 20px; line-height: 20px; background: white; } .white_content .close a { color:#333; text-decoration:none; font-size:14px; font-weight:700 }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。
jquery图片预览插件实现方法详解
- Author -
罗小树声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@