Skip to content

Commit fdec41c

Browse files
fixed-card-responsiveness
Signed-off-by: greedy_wudpeckr <[email protected]>
1 parent 5b4850a commit fdec41c

File tree

1 file changed

+145
-13
lines changed

1 file changed

+145
-13
lines changed

src/components/Card/Card.style.js

Lines changed: 145 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ export const CardWrapper = styled.div`
77
background-Color:${props => props.theme.grey212121ToWhite};
88
box-shadow: 0px 2px 6px 0px ${props => props.theme.green00D3A9ToBlackTwo};
99
transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
10+
/* Fix: Ensure the card doesn't overflow its container */
11+
overflow: hidden;
12+
display: flex;
13+
flex-direction: column;
1014
1115
&:hover{
1216
box-shadow: 0px 2px 15px 4px ${props => props.theme.whiteNineToBlackOne};
@@ -40,6 +44,8 @@ export const CardWrapper = styled.div`
4044
height: 11.5rem;
4145
border-top-right-radius: 0.5rem;
4246
border-top-left-radius: 0.5rem;
47+
/* Fix: Prevent shrinking on mobile */
48+
flex-shrink: 0;
4349
4450
.gatsby-image-wrapper, .old-gatsby-image-wrapper{
4551
height:100%;
@@ -52,6 +58,9 @@ export const CardWrapper = styled.div`
5258
display: block;
5359
text-align: center;
5460
margin: auto;
61+
/* Fix: Ensure images don't overflow */
62+
width: 100%;
63+
object-fit: cover;
5564
}
5665
5766
}
@@ -60,70 +69,142 @@ export const CardWrapper = styled.div`
6069
.post-content-block{
6170
padding: 1rem 2rem;
6271
height: 8rem;
72+
/* Fix: Allow content to grow and add proper overflow handling */
73+
flex: 1;
74+
display: flex;
75+
flex-direction: column;
76+
min-height: 8rem;
77+
78+
/* Fix: Ensure padding works on all screen sizes */
79+
@media screen and (max-width: 480px) {
80+
padding: 1rem 1rem;
81+
min-height: 9rem;
82+
}
83+
84+
@media screen and (max-width: 320px) {
85+
padding: 0.75rem;
86+
min-height: 10rem;
87+
}
6388
}
6489
6590
@media screen and (max-width: 1200px) and (min-width: 992px){
6691
.post-thumb-block{
6792
height: 12rem;
68-
6993
}
7094
7195
.post-content-block{
72-
height: 10rem;
96+
min-height: 10rem;
7397
}
74-
75-
7698
}
7799
78-
79100
@media screen and (max-width: 670px) and (min-width: 560px){
80101
.post-content-block{
81-
height: 10rem;
82-
102+
min-height: 10rem;
83103
}
84104
}
85105
86106
@media screen and (max-width: 350px){
87107
.post-content-block{
88-
height: 10rem;
108+
min-height: 10rem;
89109
}
90110
}
91111
92112
.post-title{
93113
font-size: 1.4rem;
94114
font-weight: 400;
95-
white-space: nowrap;
115+
/* Fix: Replace single-line truncation with multi-line for better mobile experience */
116+
display: -webkit-box;
117+
-webkit-line-clamp: 2;
118+
-webkit-box-orient: vertical;
96119
overflow: hidden;
97-
text-overflow: ellipsis;
120+
line-height: 1.3;
121+
margin-bottom: 0.5rem;
122+
123+
/* Fix: Responsive font sizing */
124+
@media screen and (max-width: 768px) {
125+
font-size: 1.2rem;
126+
-webkit-line-clamp: 3;
127+
}
128+
129+
@media screen and (max-width: 480px) {
130+
font-size: 1.1rem;
131+
}
132+
133+
@media screen and (max-width: 320px) {
134+
font-size: 1rem;
135+
}
98136
}
99137
100138
.post-meta-block{
101139
height: auto;
102140
display: flex;
103-
margin-buttom: 0.5rem;
141+
margin-bottom: 0.5rem;
142+
/* Fix: Better responsive behavior for meta information */
143+
flex-wrap: wrap;
144+
gap: 0.5rem;
104145
146+
/* Fix: Stack on very small screens */
147+
@media screen and (max-width: 400px) {
148+
flex-direction: column;
149+
gap: 0.25rem;
150+
}
105151
106152
.author{
107153
text-align: end;
154+
/* Fix: Don't force text-align on small screens */
155+
@media screen and (max-width: 400px) {
156+
text-align: left;
157+
}
108158
}
109159
.author, p{
110160
color: ${props => props.theme.whiteSixToBlackSix};
111161
font-size: 0.9rem;
112162
font-weight: 400;
113163
flex: auto;
114164
transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
165+
/* Fix: Prevent text overflow */
166+
word-break: break-word;
167+
168+
@media screen and (max-width: 480px) {
169+
font-size: 0.85rem;
170+
}
171+
172+
@media screen and (max-width: 320px) {
173+
font-size: 0.8rem;
174+
}
115175
}
116176
.type{
117177
text-align: end;
118178
font-size: 1rem;
119179
font-weight: 400;
180+
/* Fix: Responsive type sizing */
181+
@media screen and (max-width: 480px) {
182+
font-size: 0.9rem;
183+
}
184+
185+
@media screen and (max-width: 400px) {
186+
text-align: left;
187+
}
188+
189+
@media screen and (max-width: 320px) {
190+
font-size: 0.85rem;
191+
}
120192
}
121193
}
122194
123195
.readmore-btn-wrapper{
124-
display:flex;
196+
display: flex;
125197
justify-content: flex-start;
198+
/* Fix: Add margin-top auto to push buttons to bottom */
199+
margin-top: auto;
200+
/* Fix: Better responsive spacing */
201+
gap: 0.5rem;
202+
align-items: center;
126203
204+
/* Fix: Stack buttons on very small screens if needed */
205+
@media screen and (max-width: 320px) {
206+
flex-wrap: wrap;
207+
}
127208
}
128209
129210
.readmore-btn::after{
@@ -135,26 +216,54 @@ export const CardWrapper = styled.div`
135216
right: 0;
136217
bottom: 0;
137218
}
219+
138220
.readmore-btn, .external-link-btn{
139221
color: ${props => props.theme.whiteFourToBlackFour};
140222
display: flex;
141223
flex: auto;
142224
align-items: center;
143225
transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
226+
/* Fix: Prevent text overflow in buttons */
227+
white-space: nowrap;
228+
min-width: 0; /* Allow flexbox to shrink */
144229
230+
/* Fix: Better touch targets on mobile */
231+
@media screen and (max-width: 768px) {
232+
min-height: 44px;
233+
padding: 0.5rem;
234+
}
145235
146236
svg{
147237
font-size: 1.5rem;
148238
transition: all 0.3s;
239+
/* Fix: Prevent icon from shrinking */
240+
flex-shrink: 0;
241+
242+
@media screen and (max-width: 480px) {
243+
font-size: 1.3rem;
244+
}
149245
}
150246
}
151247
152248
.external-link-btn{
153249
justify-content: flex-end;
250+
/* Fix: Limit width so it doesn't take too much space */
251+
flex: 0 0 auto;
252+
max-width: 60px;
253+
154254
svg{
155255
font-size: 2rem;
156256
padding: 0.25rem;
157257
position: relative;
258+
259+
@media screen and (max-width: 480px) {
260+
font-size: 1.8rem;
261+
padding: 0.2rem;
262+
}
263+
264+
@media screen and (max-width: 320px) {
265+
font-size: 1.6rem;
266+
}
158267
}
159268
160269
&:hover{
@@ -164,4 +273,27 @@ export const CardWrapper = styled.div`
164273
}
165274
}
166275
}
167-
`;
276+
277+
/* Fix: Additional mobile-specific improvements */
278+
@media screen and (max-width: 768px) {
279+
.post-block {
280+
margin-bottom: 1.5rem;
281+
}
282+
}
283+
284+
@media screen and (max-width: 480px) {
285+
.post-block {
286+
margin-bottom: 1rem;
287+
}
288+
289+
.post-thumb-block {
290+
height: 10rem;
291+
}
292+
}
293+
294+
@media screen and (max-width: 320px) {
295+
.post-thumb-block {
296+
height: 9rem;
297+
}
298+
}
299+
`;

0 commit comments

Comments
 (0)