jQuery/CSS:Div 继承动态调整大小图像的宽度

发布于 2024-12-22 04:51:16 字数 463 浏览 5 评论 0原文

我有一个可以动态调整大小的图像。

该图像是图库的一部分,因此在右上角/右上角,我有缩略图来查看该图库中的图像。

拇指和图像都包含在类 .slider 的 div 中。

.slider div 始终拉伸到浏览器的宽度,并且拇指相对于 .slider 定位。

如果我能让 .slider div 始终反映图像的宽度,那就完美了,因为这样拇指将始终与图像右侧齐平(而不是像浏览器窗口那样)现在)。

请记住,图像可以在垂直和水平方向上动态调整大小,因此我必须去除图像的宽度和高度。

这是实际示例的链接:http://peteryang.com/v02/image/tylenol/

I have an image that is dynamically resizable.

The image is part of a gallery, so on the top/right corner, I have thumbnails to view images in that gallery.

Both the thumbs and image are contained within a div with class .slider.

The .slider div always stretches to width of browser, and the thumbs are positioned relative to the .slider.

If I can get the .slider div to always reflect the width of the image, it would be perfect, because then the thumbs would always flush right with the image (instead of the browser window, as it does now).

Remember the image is dynamically resizable vertically and horizontally, so I had to strip the image width and height.

Here is link of actual sample: http://peteryang.com/v02/image/tylenol/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不如归去 2024-12-29 04:51:16

使用 jQuery 在图像加载或显示或调整大小上附加一个事件(只需 google 即可),并在事件处理程序中找到图像的宽度和高度,并设置父 div 的宽度和高度

$("#imageid").resize(function(){
    //set the dimensions of the div
});

Attach an event on the image load or show or resize using jQuery (just google it) and in the event handler find the width and height of the image and set the width and height of your parent div

$("#imageid").resize(function(){
    //set the dimensions of the div
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文