I've got a <div>
, that's a certain height
and width
, and overflow:hidden
so that specfic inner images are clipped; however I want one image in the <div>
to pop out of the border (ie to override the overflow:hidden
), how do I do this?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
- Adding a timeout to a render function in ReactJS
Z-index doesnt seem to work, but here I have a workaround which worked fine for me, as I needed overflow only to be "visible" when hovering a child element:
I know this is an old post, but this can be done (at least in Chrome). I figured this out about two years ago and it's saved me a couple times.
Set the child to have position of fixed and use margins instead of top and left to position it.
Here is an example: http://jsfiddle.net/senica/Cupmb/
There is currently no way I am aware of to make a parent node with overflow hidden have children visible outside it (with the exception of
position:fixed
children).HOWEVER, it is possible to instead of using overflow, you can just use the outline property set to the color of the background combined with the z-index property to mask some elements while retaining others like so.
All the above is nice but nothing beats
JAVASCRIPT
. (Usingjquery
). So,What I do is, get the original position of the element (relative to the page), optionally get the height or width, optionally append the element to the body, apply the new css rule
position : fixed
and finally apply the original position and optionally width and height.The trick is to keep the
overflow:hidden
element withposition:static
and position the overflowing element relative to a higher parent (rather than theoverflow:hidden
parent). Like so:I also want to note, a very common use case for the desire to have an element overflow its container in this way is when you want animate the height of a dropdown or container from X to 0, and therefore need to have
overflow: hidden
on the container. Usually you have something inside the container that you want to overflow regardless. Since these elements are only accessibly when the container is "open", you can take advantage and set the overflow back tovisible
after the container is fully open, and then set it back tohidden
before trying to animate the container back toheight: 0
.You can overflow an element out of the div by wrapping it in another div, then set your image as position:absolute; and offset it using margins.
Example (tested in firefox + IE10) http://jsfiddle.net/Ps76J/