Skip to content

Commit 19dd444

Browse files
committed
Centers the image within that container using flexbox
1 parent ece5b11 commit 19dd444

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

assets/css/extended/image-zoom-in.css

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,24 @@
2424
z-index: 998;
2525
}
2626

27-
/* Style for the zoomed image */
28-
.post-content input[type="checkbox"]:checked ~ label > img {
27+
/* The zoomed state - make label take up full viewport */
28+
.post-content input[type="checkbox"]:checked ~ label {
2929
position: fixed;
30-
top: 50%;
31-
left: 50%;
32-
transform: translate(-50%, -50%) scale(1);
33-
max-height: 90vh; /* Maximum height: 90% of viewport height */
34-
max-width: 90vw; /* Maximum width: 90% of viewport width */
30+
top: 0;
31+
left: 0;
32+
width: 100%;
33+
height: 100%;
34+
display: flex;
35+
/* Centers the image within that container using flexbox */
36+
align-items: center;
37+
justify-content: center;
38+
z-index: 999;
39+
}
40+
41+
/* Style for the zoomed image */
42+
.post-content input[type="checkbox"]:checked ~ label > img.zoomCheck {
43+
max-height: 95vh;
44+
max-width: 95vw;
3545
width: auto;
3646
height: auto;
3747
object-fit: contain;
@@ -42,9 +52,12 @@
4252

4353
/* Normal image style */
4454
.post-content img.zoomCheck {
45-
transition: all 0.3s ease;
55+
transition: transform 0.3s ease;
4656
cursor: zoom-in;
57+
display: block;
4758
max-width: 100%;
4859
height: auto;
60+
transform-origin: center;
61+
z-index: 1;
4962
}
5063
}

0 commit comments

Comments
 (0)