Here is my codepen : https://codepen.io/Johngtrs/pen/oNWLYEw
I have two problems. First when I click on the rotate button the image overlap on the other row (landscape) or on other columns when the default image orientation is portrait. And for the 2nd problem it's the image size in portrait orientation. It's too big. So in my codepen I set different images size to show you my problem like this :
1300x740 1300x740
500x1300 1300x740
1300x500 1300x740
I think I have an idea to solve this but I don't know how can I do that. My idea is to initialize the container and image size.
To solve the row overlapping problem, each row height container will be set by the largest side. If we are in portrait so the height of the row container will be the height of the image. If we are in landscape, so the height of the container will be the width. Like that each time I rotate my image it will not overlap on the other rows.
To solve the width problem to not overlap on the other columns when the default image orientation is portrait I want to initialize the image size like it should be. For example if you take these images in my codepen 500x1300 and 1300x500 if you rotate the 1300x500 image it's ok because this is the good size so I'd like to reduce the size of the 500x1300 to get the same size as 500x1300 to get a normal size and keep the image centered in the column. And I want to keep it responsive.
So I don't know if there is a good way to do that by using flexbox or something else to solve overlap problem.
CSS:
.row-documents {
display: flex;
flex-direction: row;
align-items: center;
}
.row-documents img {
width: 615px;
}
.img-document {
transition: all 0.3s ease;
}
.rotate-button {
margin: 0 10px;
width: 50px;
display: flex;
justify-content: center;
}
HTML:
<div class="box">
<div class="row-documents">
<div class="img-document">
<img src="https://picsum.photos/1300/740" class="img-responsive">
</div>
<div class="rotate-button">
<button class="btn btn-default btn-rotate">
Rotate
</button>
</div>
<div class="img-document">
<img src="https://picsum.photos/1300/740" class="img-responsive">
</div>
<div class="rotate-button">
<button class="btn btn-default btn-rotate">
Rotate
</button>
</div>
</div>
<hr />
<div class="row-documents">
<div class="img-document">
<img src="https://picsum.photos/500/1300" class="img-responsive">
</div>
<div class="rotate-button">
<button class="btn btn-default btn-rotate">
Rotate
</button>
</div>
<div class="img-document">
<img src="https://picsum.photos/1300/740" class="img-responsive">
</div>
<div class="rotate-button">
<button class="btn btn-default btn-rotate">
Rotate
</button>
</div>
</div>
<hr />
<div class="row-documents">
<div class="img-document">
<img src="https://picsum.photos/1300/500" class="img-responsive">
</div>
<div class="rotate-button">
<button class="btn btn-default btn-rotate">
Rotate
</button>
</div>
<div class="img-document">
<img src="https://picsum.photos/1300/740" class="img-responsive">
</div>
<div class="rotate-button">
<button class="btn btn-default btn-rotate">
Rotate
</button>
</div>
</div>
</div>