繁体   English   中英

隐藏溢出时,仅显示可见图像

[英]When overflow hidden get only visible images

我有一个显示为图像的html结构。 当容器设置为隐藏溢出时,有什么方法可以使那些不完全可见的图像(最后一行)? 我能够获取隐藏的图像。

在此处输入图片说明

您可以使用此自定义选择器来查找不会溢出其父元素的元素:

jQuery.extend(jQuery.expr[':'], {
    inparent: function(el) {
        var $el = $(el),
        parent = $el.parent();
        if ($el.offset().top >= parent.offset().top && 
            $el.offset().top + $el.outerHeight(true) <= parent.offset().top + parent.outerHeight(true) && 
            $el.offset().left >= parent.offset().left && 
            $el.offset().left + $el.outerWidth(true) <= parent.offset().left + parent.outerWidth(true)) 
        {
            return true;
        }
        return false;
    }
});

然后,您可以使用以下方法找到部分或全部隐藏的图像:

var visibleimg = $('#container > img:not(:inparent)');

暂无
暂无

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

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