Skip to content

Commit b26d834

Browse files
authored
Update styles.css
image size changed make hero responsive
1 parent 9ca998f commit b26d834

File tree

1 file changed

+66
-17
lines changed

1 file changed

+66
-17
lines changed

styles.css

Lines changed: 66 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,52 +72,101 @@ body, p {
7272
display: flex;
7373
justify-content: space-between;
7474
align-items: center;
75-
padding: 60px;
75+
padding: 60px 40px;
7676
gap: 40px;
77+
background-color: #1f2937;
78+
flex-wrap: wrap;
7779
}
78-
.hero {
79-
flex: 1;
80-
max-width: 50%;
80+
81+
.hero-container>div {
82+
flex: 2;
83+
max-width: 500px;
84+
text-align: left;
85+
flex-basis: auto;
86+
min-width: 280px;
8187
}
8288

83-
.hero h1 {
89+
/* Heading */
90+
.hero {
8491
font-size: 48px;
8592
font-weight: 800;
93+
color: #f9faf8;
8694
margin-bottom: 10px;
87-
padding-bottom: 30px;
8895
}
8996

90-
.hero p {
97+
/* Paragraph */
98+
.hero-p {
9199
font-size: 18px;
92100
color: #e5e7eb;
93101
margin-bottom: 30px;
94102
}
95103

96-
.hero button {
104+
/* Button */
105+
.hero-button {
97106
padding: 10px 20px;
98107
background-color: #3882f6;
99108
color: #e5e7eb;
100109
font-weight: bold;
101110
border: none;
102111
border-radius: 5px;
103112
cursor: pointer;
113+
text-decoration: none;
104114
}
105115

106-
.hero button:hover {
116+
.hero-button:hover {
107117
background-color: darkblue;
108118
}
109119

120+
/* Image */
110121
.hero-image {
111-
flex: 1;
122+
flex: 1 1 350px;
123+
/* Default flex-basis for larger screens */
124+
max-width: 500px;
125+
/* MOST IMPORTANT: Ensures the image never overflows its allocated space */
126+
height: auto;
127+
/* Crucial: Maintains aspect ratio */
128+
object-fit: cover;
129+
border-radius: 5px;
130+
/* object-position: center; You can try 'top', 'bottom', 'left', 'right' if central cropping is bad */
131+
padding-right: 30px;
112132
}
113133

114-
.hero-image img {
115-
width: 400px;
116-
height: 300px;
117-
display: flex;
118-
align-items: center;
119-
justify-content: center;
134+
/* Responsive Layout */
135+
@media (max-width: 768px) {
136+
.hero-container {
137+
flex-direction: column;
138+
/* Stacks items vertically on mobile */
139+
text-align: center;
140+
/* Centers text content */
141+
padding: 40px 20px;
142+
/* Adjust padding for smaller screens */
143+
gap: 20px;
144+
/* Adjust gap for smaller screens */
145+
}
146+
147+
/* Adjustments for the text content block on small screens */
148+
.hero-container>div {
149+
flex: 1 1 auto;
150+
/* Allow text block to take full width of container */
151+
max-width: 100%;
152+
/* Ensure it doesn't try to be too wide */
153+
min-width: unset;
154+
/* Remove min-width to allow more flexibility if needed */
155+
text-align: center;
156+
}
157+
158+
/* Adjustments for the image on small screens */
159+
.hero-image {
160+
flex: 1 1 auto;
161+
/* Allow image to take full width available for a single item */
162+
max-width: 100%;
163+
/* Already set above, but good to reinforce */
164+
max-height: 300px;
165+
width: 100%;
166+
/* Ensure it takes full available width when stacked */
167+
}
120168
}
169+
121170
/*Books Section*/
122171
h2 {
123172
font-size: 36px;
@@ -398,4 +447,4 @@ footer {
398447
.footer-text {
399448
text-align: center;
400449
padding-bottom: 30px;
401-
}
450+
}

0 commit comments

Comments
 (0)