mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-09 07:36:30 +02:00
feat: Update contents
This commit is contained in:
126
contents/stepper-input.mdx
Normal file
126
contents/stepper-input.mdx
Normal file
@@ -0,0 +1,126 @@
|
||||
---
|
||||
category: Input
|
||||
created: '2019-11-16'
|
||||
description: Create a stepper input with CSS flexbox
|
||||
keywords: css flexbox, css stepper input
|
||||
thumbnail: /assets/css-layout/thumbnails/stepper-input.png
|
||||
title: Stepper input
|
||||
---
|
||||
|
||||
## HTML
|
||||
|
||||
```html
|
||||
<div class="stepper-input">
|
||||
<!-- Minus button -->
|
||||
<button class="stepper-input__button">-</button>
|
||||
|
||||
<!-- Input container -->
|
||||
<div class="stepper-input__content">
|
||||
<input type="text" class="stepper-input__input" />
|
||||
</div>
|
||||
|
||||
<!-- Plus button -->
|
||||
<button class="stepper-input__button">+</button>
|
||||
</div>
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
```css
|
||||
.stepper-input {
|
||||
display: flex;
|
||||
|
||||
/* Border */
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 0.25rem;
|
||||
|
||||
/* Size */
|
||||
height: 2rem;
|
||||
}
|
||||
|
||||
.stepper-input__button {
|
||||
/* Reset */
|
||||
background: #d1d5db;
|
||||
border: none;
|
||||
|
||||
/* Center the content */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
/* Size */
|
||||
width: 2rem;
|
||||
}
|
||||
|
||||
.stepper-input__content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.stepper-input__input {
|
||||
/* Reset */
|
||||
border: none;
|
||||
|
||||
/* Take full size of its container */
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
```
|
||||
|
||||
<Playground>
|
||||
```css styles.css hidden
|
||||
body {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.stepper-input {
|
||||
display: flex;
|
||||
|
||||
/* Border */
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 0.25rem;
|
||||
|
||||
/* Size */
|
||||
height: 2rem;
|
||||
width: 16rem;
|
||||
}
|
||||
|
||||
.stepper-input__button {
|
||||
/* Reset */
|
||||
background: #d1d5db;
|
||||
border: none;
|
||||
|
||||
/* Center the content */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
/* Size */
|
||||
width: 2rem;
|
||||
}
|
||||
|
||||
.stepper-input__content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.stepper-input__input {
|
||||
/* Reset */
|
||||
border: none;
|
||||
|
||||
/* Take full size of its container */
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
```
|
||||
|
||||
```html index.html hidden
|
||||
<div class="stepper-input">
|
||||
<button class="stepper-input__button">-</button>
|
||||
<div class="stepper-input__content">
|
||||
<input type="text" class="stepper-input__input" />
|
||||
</div>
|
||||
<button class="stepper-input__button">+</button>
|
||||
</div>
|
||||
```
|
||||
</Playground>
|
Reference in New Issue
Block a user