<div class="qty-container">
<label>Quantity</label>
<div class="qty-selector">
<button class="qty-btn minus" aria-label="Decrease">-</button>
<input type="number" class="qty-input" value="1" min="1" max="10">
<button class="qty-btn plus" aria-label="Increase">+</button>
</div>
</div>.qty-container {
font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
display: inline-block;
}
label {
display: block;
margin-bottom: 8px;
font-weight: 500;
color: #374151;
font-size: 0.9rem;
}
.qty-selector {
display: flex;
align-items: center;
border: 1px solid #d1d5db;
border-radius: 8px;
overflow: hidden;
width: 120px;
}
.qty-btn {
width: 35px;
height: 35px;
border: none;
background: #f9fafb;
cursor: pointer;
font-size: 1.2rem;
color: #374151;
display: flex;
align-items: center;
justify-content: center;
transition: background 0.2s;
}
.qty-btn:hover {
background: #e5e7eb;
}
.qty-input {
width: 50px;
height: 35px;
border: none;
border-left: 1px solid #d1d5db;
border-right: 1px solid #d1d5db;
text-align: center;
font-size: 1rem;
-moz-appearance: textfield;
outline: none;
color: #1f2937;
}
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}const minusBtn = document.querySelector(".minus");
const plusBtn = document.querySelector(".plus");
const input = document.querySelector(".qty-input");
minusBtn.addEventListener("click", () => {
let val = parseInt(input.value);
if (val > 1) {
input.value = val - 1;
}
});
plusBtn.addEventListener("click", () => {
let val = parseInt(input.value);
if (val < 10) {
input.value = val + 1;
}
});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.