简体   繁体   English

打开的图像的宽度/高度(图库)

[英]Width/Height of an opened image (Gallery)

Im working on a site's gallery which is made of a thumbnail block displaying all the pictures and a section for displaying a specific image. 我正在网站的画廊上工作,该画廊由显示所有图片的缩略图块和用于显示特定图像的部分组成。

This is the code i use to display the thumbnail and the image in its real size. 这是我用来显示缩略图和真实大小的图像的代码。

<a class="thumb" name="tuzla1" href="http://hkdnapredak.com/root/images/stories/Tuzla2011.jpg" title="Tuzla">
 <img height="75" width="75" src="http://hkdnapredak.com/root/images/stories/Tuzla2011.jpg" alt="Tuzla" />
</a>

The problem is: I can't think of anything to set the size of the opened image. 问题是:我想不出什么来设置打开图像的大小。 Setting the thumbnail size is fine: height="75" width="75" but the size of the opened one is the problem. 设置缩略图的大小很好:height =“ 75” width =“ 75”,但是打开的缩略图的大小是个问题。

Using this method, you can't set the size of the image you're linking to. 使用此方法,您无法设置要链接到的图像的大小。 It's going to open in the browsers with no HTML associated with it, so it will open at it's full size (or scaled to fit, depending on the browser). 它将在没有关联HTML的浏览器中打开,因此它将以其完整尺寸(或缩放以适合浏览器的大小)打开。

The solution is to link to a page that contains the image. 解决方案是链接到包含图像的页面。 This lets you set code that determines the image size. 这使您可以设置确定图像尺寸的代码。 However, this is a manual process - 500 images will require 500 custom pages. 但是,这是一个手动过程-500张图像将需要500个自定义页面。 Not ideal. 不理想。

If you get more sophisticated, you can build a script and pass it and image name, height and width, then dynamically build the page to display the image at the given height and width. 如果您变得更复杂,则可以构建脚本并传递脚本以及图像名称,高度和宽度,然后动态构建页面以指定高度和宽度显示图像。 Then you can display an arbitrary number of images with 1 script. 然后,您可以使用1个脚本显示任意数量的图像。

Another way to go is with a lightbox plugin which lets you pop the full sized image up into a box over top of the rest of the page. 另一种方法是使用灯箱插件,该插件可让您将完整尺寸的图片弹出到页面其余部分上方的框中。 You've probably seen this method used on Facebook or other sites - it's popular and doesn't take that much effort to use. 您可能已经在Facebook或其他网站上看到了这种方法-它很流行并且不需要花费太多精力。 I like it because you don't have to leave the page you're on, and you can show lots of photos on a fairly compact page. 我喜欢它是因为您不必离开当前页面,并且可以在相当紧凑的页面上显示很多照片。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM