I’m trying to place an image in a relative container (which has a width and height) 20px from the top, left and right like this:
<div style="position: relative; height: 100px; width: 200px">
<img src="x" style="position: absolute; top: 20px; left: 20px; right: 20px;">
</div>
My image however, as it doesn’t have a width set is just defaulting to its own width and overflowing (the parent have overflow hidden).
Any ideas how to make this work? I may have some other CSS which is causing the issue but I tried to just give a clean example.
2
Answers
Do it like that, Its working.
Try it like this. It will work