mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-09-08 21:30:50 +02:00
feat: Search box
This commit is contained in:
4
contents/_includes/patterns/search-box.njk
Normal file
4
contents/_includes/patterns/search-box.njk
Normal file
@@ -0,0 +1,4 @@
|
||||
<div class="search-box">
|
||||
<input type="text" class="search-box__input" />
|
||||
{% circle "md" %}
|
||||
</div>
|
@@ -94,6 +94,7 @@ eleventyExcludeFromCollections: true
|
||||
{% pattern "Input addon" %}{% include "patterns/input-addon.njk" %}{% endpattern %}
|
||||
{% pattern "Radio switch" %}{% include "patterns/radio-switch.njk" %}{% endpattern %}
|
||||
{% pattern "Rating" %}{% include "patterns/rating.njk" %}{% endpattern %}
|
||||
{% pattern "Search box" %}{% include "patterns/search-box.njk" %}{% endpattern %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
40
contents/search-box.md
Normal file
40
contents/search-box.md
Normal file
@@ -0,0 +1,40 @@
|
||||
---
|
||||
layout: layouts/post.njk
|
||||
title: Search box
|
||||
description: Create a search box with CSS flexbox
|
||||
keywords: css flexbox, css search box
|
||||
---
|
||||
|
||||
## HTML
|
||||
|
||||
```html
|
||||
<div class="search-box">
|
||||
<!-- Text input -->
|
||||
<input type="text" class="search-box__input" />
|
||||
|
||||
<!-- Search icon sticks to the left or right -->
|
||||
...
|
||||
</div>
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
```css
|
||||
.search-box {
|
||||
display: flex;
|
||||
|
||||
/* If you want to place the icon before the text input */
|
||||
flex-direction: row-reverse;
|
||||
|
||||
/* Border */
|
||||
border: 1px solid #d1d5db;
|
||||
}
|
||||
|
||||
.search-box__input {
|
||||
border-color: transparent;
|
||||
/* Take available width */
|
||||
flex: 1;
|
||||
}
|
||||
```
|
||||
|
||||
{% demo %}{% include "patterns/search-box.njk" %}{% enddemo %}
|
Reference in New Issue
Block a user