Skip to content

Commit 4697102

Browse files
authored
Avoid overflow of gallery images (#79)
* fix cover images * fix images cover
1 parent e03cb5a commit 4697102

File tree

2 files changed

+40
-17
lines changed

2 files changed

+40
-17
lines changed
Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
11
.galleryWrapper {
2-
margin: 30px 0;
2+
position: relative;
3+
width: 100%;
4+
overflow: hidden;
5+
}
6+
7+
.splide__slide {
8+
position: relative;
9+
width: 100%;
10+
height: 100%; /* Ensure the slide has a valid height */
11+
overflow: hidden;
12+
}
13+
14+
.splideSlide {
15+
position: relative;
16+
width: 100%;
17+
height: 0;
18+
padding-bottom: 56.25%; /* 16:9 aspect ratio */
19+
overflow: hidden;
320
}
421

522
.screenshot {
6-
border-radius: 6px;
23+
position: absolute;
24+
top: 0;
25+
left: 0;
26+
width: 100%;
27+
height: 100%;
28+
object-fit: cover;
729
}

components/tools/toolPage/ToolGallery/ToolGallery.tsx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,27 @@ const ToolGallery: FC<ToolGalleryProps> = ({ tool, screenshots }) => {
4848
screenshot.url.includes('youtube.com') ? (
4949
<SplideSlide
5050
key={`${screenshot.path}-${index}`}
51-
// add youtube link if youtube video
5251
data-splide-youtube={screenshot.url}>
53-
<Image
54-
className={styles.screenshot}
55-
width={1280}
56-
height={720}
57-
src={screenshot.path}
58-
alt={`${tool.name} screenshot`}
59-
/>
52+
<div className={styles.splideSlide}>
53+
<Image
54+
className={styles.screenshot}
55+
src={screenshot.path}
56+
alt={`${tool.name} screenshot`}
57+
fill={true}
58+
/>
59+
</div>
6060
</SplideSlide>
6161
) : (
6262
<SplideSlide
6363
key={`${screenshot.path}-${index}`}>
64-
<Image
65-
className={styles.screenshot}
66-
width={1280}
67-
height={720}
68-
src={screenshot.path}
69-
alt={`${tool.name} screenshot`}
70-
/>
64+
<div className={styles.splideSlide}>
65+
<Image
66+
className={styles.screenshot}
67+
src={screenshot.path}
68+
alt={`${tool.name} screenshot`}
69+
fill={true}
70+
/>
71+
</div>
7172
</SplideSlide>
7273
),
7374
)}

0 commit comments

Comments
 (0)