I am trying to "move" an image inside a div
which is adjusted with object-fit: cover;
and object-position: center;
.
My question is: Can I move the center-positioned image a few pixels to the right without to remove the object-*
from my css?
.myDiv {
width: 150px;
height: 150px;
margin: 0 15px;
}
.myDiv.before img {
width: 100%;
height: 100%;
}
.myDiv.after img {
width: 100%;
height: 100%;
object-fit: cover;
object-position: center;
}
.general {
display: flex;
}
<div class="general">
<div class="myDiv before">
<img src="https://via.placeholder.com/400x250">
</div>
<div class="myDiv after">
<img src="https://via.placeholder.com/400x250">
</div>
</div>
I would like to NOT resize the image as in .after
, but moving the image a few px
right/left in the div. Is there a way to do it?