1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-08-30 09:09:50 +02:00

feat: Tab

This commit is contained in:
Phuoc Nguyen
2022-09-21 15:56:16 +07:00
parent 151fed0eaa
commit ab1e4a12c4
7 changed files with 99 additions and 171 deletions

View File

@@ -0,0 +1,11 @@
<div class="tab">
<div class="tab__item tab__item--active">
{% circle %}
</div>
<div class="tab__item tab__item--inactive">
{% circle %}
</div>
<div class="tab__item tab__item--inactive">
{% circle %}
</div>
</div>

View File

@@ -129,6 +129,7 @@ eleventyExcludeFromCollections: true
{% pattern "Circular navigation" %}{% include "covers/circular-navigation.njk" %}{% endpattern %}
{% pattern "Dot navigation" %}{% include "covers/dot-navigation.njk" %}{% endpattern %}
{% pattern "Drawer" %}{% include "covers/drawer.njk" %}{% endpattern %}
{% pattern "Tab" %}{% include "covers/tab.njk" %}{% endpattern %}
{% pattern "Wizard" %}{% include "covers/wizard.njk" %}{% endpattern %}
</div>
</div>

58
contents/tab.md Normal file
View File

@@ -0,0 +1,58 @@
---
layout: layouts/post.njk
title: Tab
description: Create tabs with CSS flexbox
keywords: css flexbox, css navigation, css tab
---
## HTML
```html
<div class="tab">
<!-- Active tab -->
<div class="tab__item tab__item--active">
...
</div>
<!-- Inactive tab -->
<div class="tab__item tab__item--inactive">
...
</div>
</div>
```
## CSS
```css
.tab {
/* Center the content */
align-items: center;
display: flex;
justify-content: center;
}
.tab__item {
border-top-left-radius: 0.25rem;
border-top-right-radius: 0.25rem;
padding: 0.5rem 1rem;
}
.tab__item--active {
/* Border */
border: 1px solid #d1d5db;
/* Hide the bottom border */
border-bottom-color: transparent;
/* Border radius */
border-top-left-radius: 2px;
border-top-right-radius: 2px;
}
.tab__item--inactive {
/* Has only the bottom border */
border-bottom: 1px solid #d1d5db;
}
```
{% demo %}{% include "covers/tab.njk" %}{% enddemo %}