简体   繁体   English

使用“超大” jQuery插件按比例调整全屏图像的大小

[英]Proportionally resizing a full-screen image using “supersized” jQuery plugin

I'm using a jQuery plugin called Supersized to display images in full screen. 我正在使用一个名为Supersized的jQuery插件以全屏显示图像。

You can see a sample here (on homepage): http://mysampleconcept.com/situs4/ 您可以在此处(在主页上)看到一个示例: http : //mysampleconcept.com/situs4/

If you try to shrink the screen, you will notice that the image will resize too, however it may shrink too much that the image will look bad. 如果您尝试缩小屏幕,则会注意到图像也会调整大小,但是可能会缩小太多,以致图像看起来不佳。

The same plugin is used here as well: http://mysampleconcept.com/situs3/ ; 这里也使用了相同的插件: http : //mysampleconcept.com/situs3/ ; however, the resizing is done differently so the image doesn't go out of proportions. 但是,调整大小的方式有所不同,因此图像不会超出比例。

I have tried to compare the plugins settings on both sites and they both seem to be similar. 我试图比较两个站点上的插件设置,它们似乎很相似。

I have tried setting the image width and height to 100% !important in my css and it didn't help. 我试图在CSS中将图像的宽度和高度设置为100% !important ,但这没有帮助。

Any suggestion on how to achieve the same behavior? 关于如何实现相同行为的任何建议?

When I removed 当我删除

#supersized img {
 width: 100% !important;
 height: 100% !important;
}
it seems to work. 它似乎有效。

尽管不是最佳解决方案,但我能够通过在超大图像中添加min-widthmin-height来解决此问题

The issue is from the common css that does your image all base on "max-width:100%". 问题出在常见的CSS中,您的图片全部基于“最大宽度:100%”。

Check your css reset if there is something like 检查您的CSS重置是否存在类似问题

img { max-width: 100%; }

The supersized official has a solution for the file "supersized.3.2.7.js": https://github.com/buildinternet/supersized/issues/103 超大官员为文件“ supersized.3.2.7.js”提供了解决方案: https : //github.com/buildinternet/supersized/issues/103

If you can not solve it by following the official solution, try only add this in your supersized css: 如果您无法按照官方解决方案解决问题,请尝试仅将其添加到超大型CSS中:

#supersized img { max-width: none; }

this tricky is by http://blog.valderama.net/node/30 这个棘手的是通过http://blog.valderama.net/node/30

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

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