中心灯箱窗口,使其响应(Center lightbox window and make it responsive)
我为灯箱幻灯片项目创建了这个简单的JQuery代码。 到目前为止一切顺利,但我希望你能帮助我让这个窗口具有代表性吗?
这样做的数学/代码是什么?
谢谢!
$(document).ready(function(){ $('.lightbox').click(function(){ $('.backdrop, .box').animate({'opacity':'.50'}, 300, 'linear'); $('.box').animate({'opacity':'1.00'}, 300, 'linear'); $('.backdrop, .box').css('display', 'block'); }); $('.close').click(function(){ close_box(); }); $('.backdrop').click(function(){ close_box(); }); }); function close_box() { $('.backdrop, .box').animate({'opacity':'0'}, 300, 'linear', function(){ $('.backdrop, .box').css('display', 'none'); }); }
body { font-family: Helvetica, Arial; } .backdrop { position:absolute; top:0px; left:0px; width:100%; height:100%; background:#000; opacity: .0; filter:alpha(opacity=0); z-index:50; display:none; } .box { position:absolute; top:20%; left:30%; background:#ffffff; z-index:51; padding:10px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; -moz-box-shadow:0px 0px 5px #444444; -webkit-box-shadow:0px 0px 5px #444444; box-shadow:0px 0px 5px #444444; display:none; } .caption { padding-top: 10px; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <h1>Hasaboo</h1> <a href="#" class="lightbox">Open Lightbox</a> <div class="backdrop"></div> <div class="box"> <img src="http://www.dan-dare.org/FreeFun/Images/PrinceOfPersiaWallpaper21024.jpg" width="500"/> <div class="caption">CAPTION!!!!</div> </div>
I've created this simple JQuery code for lightbox slideshow project. So far it's going well, but I would like you to please help me make this window reponsive?
What's the math/code to make it so?
Thank you!
$(document).ready(function(){ $('.lightbox').click(function(){ $('.backdrop, .box').animate({'opacity':'.50'}, 300, 'linear'); $('.box').animate({'opacity':'1.00'}, 300, 'linear'); $('.backdrop, .box').css('display', 'block'); }); $('.close').click(function(){ close_box(); }); $('.backdrop').click(function(){ close_box(); }); }); function close_box() { $('.backdrop, .box').animate({'opacity':'0'}, 300, 'linear', function(){ $('.backdrop, .box').css('display', 'none'); }); }
body { font-family: Helvetica, Arial; } .backdrop { position:absolute; top:0px; left:0px; width:100%; height:100%; background:#000; opacity: .0; filter:alpha(opacity=0); z-index:50; display:none; } .box { position:absolute; top:20%; left:30%; background:#ffffff; z-index:51; padding:10px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; -moz-box-shadow:0px 0px 5px #444444; -webkit-box-shadow:0px 0px 5px #444444; box-shadow:0px 0px 5px #444444; display:none; } .caption { padding-top: 10px; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <h1>Hasaboo</h1> <a href="#" class="lightbox">Open Lightbox</a> <div class="backdrop"></div> <div class="box"> <img src="http://www.dan-dare.org/FreeFun/Images/PrinceOfPersiaWallpaper21024.jpg" width="500"/> <div class="caption">CAPTION!!!!</div> </div>
原文:https://stackoverflow.com/questions/44043509
更新时间:2023-08-14 09:08
最满意答案
您应该考虑使用
java.util.zip
包 。 Sun提供了有关如何使用它的教程: 使用Java API压缩和解压缩数据 。public static void unzip(){ try{ BufferedOutputStream out = null; ZipInputStream in = new ZipInputStream(ZipFileExtracter.class.getClassLoader().getResourceAsStream("com/artificialmachines/chitme/stamps/ChitMeData.zip")); ZipEntry entry; boolean isDirectory=false; while((entry = in.getNextEntry()) != null){ int count; byte data[] = new byte[BUFFER]; // write the files to the disk String entryName = entry.getName(); File newFile = new File(new StringBuffer().append(System.getProperty("user.dir")).append(File.separator).append(entryName).toString()); if(entryName.endsWith("/")){ isDirectory=true; newFile.mkdir(); //System.out.println("This is directory "+newFile.exists()+" IS DIr "+newFile.isDirectory()+" path "+newFile.getPath()); }else{ newFile.createNewFile(); } if(!isDirectory){ out = new BufferedOutputStream(new FileOutputStream(newFile),BUFFER); while ((count = in.read(data,0,BUFFER)) != -1){ out.write(data,0,count); } cleanUp(out); } isDirectory=false; } cleanUp(in); } catch(Exception e){ e.printStackTrace(); System.exit(0); } }
相关问答
更多-
如果你看看JarFile API,你会发现它是ZipFile类的一个子类。 特定于jar的类大多只是添加特定于jar的功能,如直接支持清单文件属性等。 这是OOP“行动中”; 由于jar文件是zip文件,jar类可以使用zip功能并提供额外的实用程序。 If you look at the JarFile API you'll see that it's a subclass of the ZipFile class. The jar-specific classes mostly just add jar ...
-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
好吧,我猜你没有创建一个getFileAsUint8Array函数(或者至少,你没有在上面显示它)。 我正在做类似的事情(虽然从XHR调用获取zip文件)。 一旦我有zip文件和我想放入zip文件的文件夹,我会做类似下面的代码。 但请注意,我必须修改此代码,因为我做了一些其他的事情,所以我没有完全按原样测试它(显然它在上面的代码中不起作用)。 这是(大部分)完整代码: WinJS.xhr({ "url": zipUrl, "responseType": "arraybuffer" }) .done( ...
-
从压缩文件中提取文件: 解压缩file.zip文件/ you / want / to / extract / the_file.txt 修改the_file.txt 把它放回去: zip file.zip文件/你/想要/提取/ the_file.txt 这应该让你开始。 Extract a file from a zip file: unzip file.zip file/you/want/to/extract/the_file.txt Modify the_file.txt Put it back: zi ...
-
这可能是由于这个JVM错误引起的(JVM-6519463) 我以前在1000个随机创建的文档中有大约一两个错误,我应用了建议的解决方案(捕获EOFException并且不执行任何操作)并且我没有更多错误。 This is probably caused by this JVM bug (JVM-6519463) I previously has about one or two errors on 1000 randomly created documents, I applied the proposed ...
-
这适合您的需求吗? public static void main(String[] args) { try { copyJarFromZip("G:\\Dateien\\Desktop\\Desktop.zip", "G:\\Dateien\\Desktop\\someJar.jar"); } catch (IOException ex) { ex.printStackTrace(); } } publ ...
-
您可以在ZipArchive上尝试foreach循环,并排除与您的参数不匹配的所有内容,然后,在循环完成后,提取最后一个文件。 像这样的东西: private void TestUnzip_Foreach() { using (ZipArchive z = ZipFile.Open("zipfile.zip", ZipArchiveMode.Read)) { string LastFile = "lastFileName.ext"; ...
-
从.zip中提取某些文件(Extract certain files from .zip)[2023-10-19]
感谢来自@ user20650的评论。 使用两个调用来unzip 。 首先用list=TRUE来获取文件的$Name 。 其次用files=来提取名称与模式匹配的文件。 zipped_csv_names <- grep('\\.csv$', unzip('some_archive.zip', list=TRUE)$Name, ignore.case=TRUE, value=TRUE) unzip('some_archive.zip', file ... -
可悲的是,似乎API没有提供足以满足您的所有要求。 为了提取单个文件,您需要遍历归档索引。 归档的简化界面使这更容易: ISimpleInArchive接口提供: ISimpleInArchiveItem[] getArchiveItems() 允许您检索存档中的项目列表。 ISimpleInArchiveItem接口提供了以下方法: java.lang.String getPath() 因此,您可以在路径上比较archiveItems。 这是违反您的要求的。 但是,请注意,它会遍历索引表, ...
-
您应该考虑使用java.util.zip包 。 Sun提供了有关如何使用它的教程: 使用Java API压缩和解压缩数据 。 public static void unzip(){ try{ BufferedOutputStream out = null; ZipInputStream in = new ZipInputStream(ZipFileExtracter.class.getClassLoader().getResourceAsStrea ...