I am trying to make an ellipse containing an image, which has a border.
I am getting almost there, however I want to rotate the image independently,
so that can bring it back to it’s original position.
This is my code:
.eclipse-outline {
width: 400px;
height: 500px;
border-radius: 50%;
border: 3px solid #fff;
overflow: hidden;
position: relative;
padding: 20px;
transform: rotate(20deg);
}
.eclipse-image {
width: 100%;
height: 100%;
}
.eclipse-image img {
height: 100%;
width: 100%;
object-fit: cover;
transform: rotate(0deg);
border-radius: 50%;
}
<div class="eclipse-outline">
<div class="eclipse-image"><img src="https://jourdan.nl/wp-content/uploads/2023/12/healthy-lifestyle-woman-eating-salad-smiling-happy-outdoors-beautiful-day-young-female-food-outside-summer-34259122.jpg" /></div>
</div>
Hope someone can help.
2
Answers
Thank for your answer, In the way you did it, I was not able to add a required border with margin. So I added a outerdiv and add padding to it, that did the work. Thanks anyway.
I removed the padding, the extra div container, and the
position relative
. Then you can rotate the image counterclockwise to the main div.