ddayan
ddayan

Reputation: 4142

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?

Upvotes: 5

Views: 14563

Answers (3)

T.J. Crowder
T.J. Crowder

Reputation: 1074228

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.

Upvotes: 13

Shlomi Komemi
Shlomi Komemi

Reputation: 5545

best way to do that

<div style="overflow:hidden">
    // place images here...
</div>

Upvotes: 0

No Results Found
No Results Found

Reputation: 102745

Add overflow:hidden to the parent div.

Upvotes: 1

Related Questions