I try to rotate an image around the bottom right corner and then move it back up to the origin using negative margin.
When I do this, there is always a few pixels of space left to the top that the browser (both IE and Chrome) refuse to move it further. If I assign position: absolute
to the image, it will get positioned correctly.
Here is a minimal example: https://jsfiddle.net/ny0rm75b/
<div>
<img src="http://placehold.it/600x300">
</div>
<div class="fixed">
<img class="fixed" src="http://placehold.it/600x300">
</div>
css:
div{
width:600px;
height: 300px;
box-sizing: content-box;
border: 5px solid orange;
margin: 15px;
}
img{
transform-origin: 600px 300px;
transform: rotate(180deg);
margin-left: -600px;
margin-top: -300px;
}
div.fixed{
position: relative;
}
img.fixed{
position:absolute;
}
Why does position: absolute
fix this issue, or rather, what is the cause of this in the first place?