Skip to content

Commit c98cba6

Browse files
committed
make cart responsive
1 parent 804772b commit c98cba6

File tree

1 file changed

+53
-9
lines changed

1 file changed

+53
-9
lines changed

src/views/Cart.vue

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<img :src="item.image" :alt="item.title" class="cart-item-image" />
77
<div class="cart-item-details">
88
<h2>{{ item.title }}</h2>
9-
<p class="price">{{ item.price | currency }}</p>
9+
<p class="price">Price: {{ item.price | currency }} USD</p>
1010
<div class="quantity-controls">
1111
<button @click="updateCartQuantity({ product: item, quantity: item.quantity - 1 })">-</button>
1212
<span>{{ item.quantity }}</span>
@@ -59,14 +59,12 @@ body {
5959
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
6060
font-family: 'Courier New', Courier, monospace;
6161
background-color: beige;
62-
6362
}
6463
6564
h1 {
6665
font-size: 2rem;
6766
margin-bottom: 20px;
6867
text-align: center;
69-
font-family: 'Courier New', Courier, monospace;
7068
}
7169
7270
.cart-content {
@@ -77,6 +75,7 @@ h1 {
7775
7876
.cart-item {
7977
display: flex;
78+
flex-direction: row;
8079
align-items: center;
8180
padding: 10px;
8281
border-bottom: 1px dashed #ddd;
@@ -143,11 +142,6 @@ h1 {
143142
}
144143
145144
.cart-summary h2 {
146-
display: flex;
147-
flex-direction: column;
148-
justify-content: center;
149-
align-items: center;
150-
width: 400px;
151145
font-size: 1.5rem;
152146
margin-bottom: 10px;
153147
}
@@ -184,5 +178,55 @@ h1 {
184178
justify-content: center;
185179
align-items: center;
186180
}
187-
</style>
188181
182+
/* Responsive styles */
183+
@media (max-width: 768px) {
184+
.cart {
185+
padding: 20px;
186+
max-width: 100%;
187+
margin: 10px;
188+
}
189+
190+
.cart-item {
191+
flex-direction: column;
192+
align-items: flex-start;
193+
}
194+
195+
.cart-item-image {
196+
width: 100%;
197+
margin: 0 0 10px 0;
198+
}
199+
200+
.quantity-controls {
201+
margin-top: 10px;
202+
}
203+
204+
.checkout-button {
205+
font-size: 0.9rem;
206+
padding: 8px 16px;
207+
}
208+
}
209+
210+
@media (max-width: 480px) {
211+
.cart {
212+
padding: 10px;
213+
}
214+
215+
h1 {
216+
font-size: 1.5rem;
217+
}
218+
219+
.cart-item-details h2 {
220+
font-size: 1rem;
221+
}
222+
223+
.cart-summary h2 {
224+
font-size: 1.2rem;
225+
}
226+
227+
.checkout-button {
228+
font-size: 0.8rem;
229+
padding: 6px 12px;
230+
}
231+
}
232+
</style>

0 commit comments

Comments
 (0)