<div class="cart-wrapper">
<div class="cart-icon">
<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="9" cy="21" r="1"></circle><circle cx="20" cy="21" r="1"></circle><path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"></path></svg>
<span class="badge">2</span>
</div>
<div class="cart-dropdown">
<div class="cart-item">
<img src="https://placehold.co/50x50/3b82f6/ffffff?text=1" alt="Item">
<div class="item-details">
<h4>Wireless Mouse</h4>
<span>1 x $25.00</span>
</div>
<span class="remove">×</span>
</div>
<div class="cart-item">
<img src="https://placehold.co/50x50/ec4899/ffffff?text=2" alt="Item">
<div class="item-details">
<h4>Keyboard</h4>
<span>1 x $45.00</span>
</div>
<span class="remove">×</span>
</div>
<div class="cart-total">
<span>Total:</span>
<strong>$70.00</strong>
</div>
<button class="checkout-btn">Checkout</button>
</div>
</div>.cart-wrapper {
font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
position: relative;
display: inline-block;
margin-left: 300px;
padding: 10px;
}
.cart-icon {
position: relative;
cursor: pointer;
color: #1f2937;
}
.badge {
position: absolute;
top: -8px;
right: -8px;
background: #ef4444;
color: white;
font-size: 0.7rem;
width: 18px;
height: 18px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
}
.cart-dropdown {
display: none;
position: absolute;
right: 0;
top: 100%;
background: #fff;
width: 300px;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
border-radius: 12px;
border: 1px solid #f3f4f6;
padding: 15px;
z-index: 100;
animation: slideUp 0.2s ease;
}
.cart-wrapper:hover .cart-dropdown {
display: block;
}
@keyframes slideUp {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.cart-item {
display: flex;
align-items: center;
gap: 12px;
padding-bottom: 12px;
border-bottom: 1px solid #f9fafb;
margin-bottom: 12px;
}
.cart-item img {
width: 50px;
height: 50px;
border-radius: 8px;
object-fit: cover;
}
.item-details h4 {
margin: 0 0 4px 0;
font-size: 0.95rem;
color: #374151;
}
.item-details span {
font-size: 0.85rem;
color: #6b7280;
}
.remove {
margin-left: auto;
color: #9ca3af;
cursor: pointer;
font-size: 1.2rem;
}
.remove:hover {
color: #ef4444;
}
.cart-total {
display: flex;
justify-content: space-between;
margin-bottom: 15px;
font-size: 1rem;
color: #1f2937;
}
.checkout-btn {
width: 100%;
padding: 10px;
background: #2563eb;
color: white;
border: none;
border-radius: 8px;
font-weight: 600;
cursor: pointer;
transition: background 0.2s;
}
.checkout-btn:hover {
background: #1d4ed8;
}Nothing to show yetType HTML, CSS or JavaScript and your page appears here.
Click any element to find its code Esc
Check this code before you run it
It came from a shared link. It runs with fewer permissions, so it cannot open pop-ups, submit forms or start downloads.
0.00s / 0.00s
Nothing has animated yet. Hover, click or type in the preview and each CSS animation, transition or
element.animate() call shows up here as it plays.