简体   繁体   English

在外面显示图像 <div> 哪里溢出:隐藏?

[英]Display image outside <div> where overflow:hidden?

I'm using Ganesh's very wonderful jCarouselLite jQuery plugin to display a scrolling series of thumbnail images at the top of a page. 我正在使用Ganesh的非常出色的jCarouselLite jQuery插件在页面顶部显示一系列滚动的缩略图。 The container div necessarily has overflow:hidden to limit the number of thumbnails displayed at any one time. 容器div一定有溢出:隐藏以限制在任何一次显示的缩略图的数量。 I would like to display a larger version of the thumbnail when the mouse hovers over it. 当鼠标悬停在缩略图上时,我想显示一个较大的缩略图。 I'm most of the way there using CSS but I can't persuade the large image to display outside the confines of the parent div due to the overflow setting and it displays "clipped" within that div. 我在大多数情况下都使用CSS,但是由于溢出设置,我无法说服大图像在父div的范围之外显示,并且在该div中显示为“剪切”。

Is this possible using CSS? 使用CSS可以吗?

There is no way to show a child element outside the bounds of a parent element that has overflow:hidden set. 无法将子元素显示在具有overflow:hidden set的父元素的边界之外。 The best way to accomplish the desired affect is to move the larger thumbnail images outside of the div that is clipped, and show/hide it with javascript. 达到预期效果的最佳方法是将较大的缩略图图像移到被裁剪的div之外,并使用javascript显示/隐藏它。

You cannot do that with css, BUT can be achived with javascript-jquery. 您无法使用CSS做到这一点,但可以使用javascript-jquery来实现。

$(function () {
    $(".div").on("mouseover", function () {

        $(this).children(".myimg").show().parents().css({overflow:'visible'});

    }).on("mouseout", function () {

        $(this).children(".myimg").hide().parents().css({overflow:'hidden'});

    });
});

You must either resize your div or move image outside overflow:hidden; 您必须调整div的大小或将图像移到overflow:hidden;之外overflow:hidden; div. div。 overflow:hidden will always clip content. overflow:hidden将始终剪辑内容。

It would be easier to help if you posted few lines of your code. 如果您发布了几行代码,将更容易获得帮助。

除非您调整容器的大小,否则CSS不可能做到这一点,但是您可以使用jQuery将图像附加到正文中,然后在缩略图上定位和设置动画。

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

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