Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to not display an image if outside of div?

I have multiple images within a div, I change thier positions using JQuery

$("#"+carElem).css({"left": pos.left+50 +"px"});

Im using absolute positioning (relative positioning gives the same result), is it possible to cut off anything that is displayed outside of the parent div .i.e make sure its not shown?

like image 670
ddayan Avatar asked Dec 16 '22 12:12

ddayan


2 Answers

Give the parent div the style overflow: hidden and go back to relative positioning (it won't work with absolute positioning).

There's probably a better way to solve the actual underlying issue, though, if we had a bit more context. But overflow: hidden will probably be part of it regardless.

like image 100
T.J. Crowder Avatar answered Dec 19 '22 07:12

T.J. Crowder


Add overflow:hidden to the parent div.

like image 33
Wesley Murch Avatar answered Dec 19 '22 06:12

Wesley Murch