为什么这些图像比原始尺寸大?
我有很多从 Facebook 上获取的图片。它们被放置在卷轴中。当您点击图像时,会出现一个带有实际图像的对话框
(滚动条中的图像是缩略图大小,您可以通过src_small
从Facebook查询中获得)
我无法确定在我得到图像之前,先确定图像的大小。有些很大,有些很小。考虑到这一点(因此所有图像都适合对话框
并且大小合理)我尝试了以下方法:
/*
* Image in the dialog div
*/
.DialogImagesBig
{
position: relative;
width: 95%;
top: 0px;
left: 10px;
}
/*
* Firefox only
*/
@-moz-document url-prefix()
{
/*
* Edits images for FF
*/
.DialogImagesBig
{
height: 95% !important;
width: 95% !important;
position: relative;
top: 0px;
left: 10px;
}
}
但它实际上使一些图像比它们实际的尺寸更大(大图像更小,但小图像更大)和像素化)。这是为什么?我该如何解决这个问题,以便所有图像都适合对话框
并且不会像素化?
编辑 我被告知我需要使用 Javascript(或 Jquery?)来完成此任务。我该怎么做呢?
I have multiple images that I pull from facebook. They are placed in a scroller. When you click on the image a dialog
appears with the actual image (The images in the scroller are thumbnail size, what you get from a facebook query with src_small
)
I cannot determine the size of the images before I get them. Some are huge and others very small. To account for this (so all images fit in the dialog
and are a reasonable size) I tried this:
/*
* Image in the dialog div
*/
.DialogImagesBig
{
position: relative;
width: 95%;
top: 0px;
left: 10px;
}
/*
* Firefox only
*/
@-moz-document url-prefix()
{
/*
* Edits images for FF
*/
.DialogImagesBig
{
height: 95% !important;
width: 95% !important;
position: relative;
top: 0px;
left: 10px;
}
}
But it actually makes some images bigger then they are (Big images are smaller, but small images are bigger and pixelated). Why is that? How would I fix this so that all images fit in the dialog
and are not pixelated?
Edit I have been told that I need to use Javascript (or Jquery?) to get this done. How would I go about doing that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
95%
的宽度/高度表示父元素宽度/高度的 95%,而不是图像原始大小的 95%。A width/height of
95%
means 95% of the parent element's width/height, not 95% of the image's original size.您可以通过执行以下操作来获取图像宽度/高度:
您可以将这些值与对话框的宽度/高度进行比较,并执行您需要的所有调整大小,我希望这可以有所帮助。
例子:
You can get the image width/height by doing this:
You can compare those values with the width/height of your dialog and do all the resizing you need, i hope this can help.
Example:
你可以尝试这样的事情:
其他比较也一样,适当缩小它。我认为数学就在那里......
You could try this sort of thing:
same for other comparisons, to shrink it down appropriately. I think the math is right there...