mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-16 19:14:08 +02:00
feat: Update contents
This commit is contained in:
171
contents/property-list.mdx
Normal file
171
contents/property-list.mdx
Normal file
@@ -0,0 +1,171 @@
|
||||
---
|
||||
category: Display
|
||||
created: '2019-11-25'
|
||||
description: Create a property list with CSS flexbox
|
||||
keywords: css flexbox, property list
|
||||
thumbnail: /assets/css-layout/thumbnails/property-list.png
|
||||
title: Property list
|
||||
---
|
||||
|
||||
## HTML
|
||||
|
||||
```html
|
||||
<!-- A property item -->
|
||||
<dl class="property-list">
|
||||
<!-- Property name -->
|
||||
<dt class="property-list__key">...</dt>
|
||||
|
||||
<!-- Property value -->
|
||||
<dd class="property-list__value">...</dd>
|
||||
</dl>
|
||||
|
||||
<!-- Repeat other items -->
|
||||
...
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
```css
|
||||
.property-list {
|
||||
/* Content is center horizontally */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
|
||||
border-bottom: 1px solid #d1d5db;
|
||||
|
||||
/* Spacing */
|
||||
margin: 0;
|
||||
padding: 0.25rem 0;
|
||||
}
|
||||
.property-list__key {
|
||||
/* Take the available width */
|
||||
flex: 1;
|
||||
}
|
||||
.property-list__value {
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
```
|
||||
|
||||
<Playground>
|
||||
```css placeholders.css hidden
|
||||
.circle {
|
||||
background: #d1d5db;
|
||||
border-radius: 9999px;
|
||||
height: var(--circle-size);
|
||||
width: var(--circle-size);
|
||||
}
|
||||
.circle--sm {
|
||||
--circle-size: 0.5rem;
|
||||
}
|
||||
.circle--md {
|
||||
--circle-size: 1.5rem;
|
||||
}
|
||||
.circle--lg {
|
||||
--circle-size: 4rem;
|
||||
}
|
||||
.rectangle {
|
||||
background: #d1d5db;
|
||||
border-radius: 0.25rem;
|
||||
height: var(--rectangle-height);
|
||||
width: var(--rectangle-width);
|
||||
}
|
||||
.rectangle--hor.rectangle--20 {
|
||||
--rectangle-width: 20%;
|
||||
}
|
||||
.rectangle--hor.rectangle--40 {
|
||||
--rectangle-width: 40%;
|
||||
}
|
||||
.rectangle--hor.rectangle--60 {
|
||||
--rectangle-width: 60%;
|
||||
}
|
||||
.rectangle--hor.rectangle--80 {
|
||||
--rectangle-width: 80%;
|
||||
}
|
||||
.rectangle--hor.rectangle--100 {
|
||||
--rectangle-width: 100%;
|
||||
}
|
||||
.rectangle--hor.rectangle--sm {
|
||||
--rectangle-height: 0.5rem;
|
||||
}
|
||||
.rectangle--hor.rectangle--md {
|
||||
--rectangle-height: 2rem;
|
||||
}
|
||||
.rectangle--hor.rectangle--lg {
|
||||
--rectangle-height: 4rem;
|
||||
}
|
||||
.rectangle--ver.rectangle--20 {
|
||||
--rectangle-height: 20%;
|
||||
}
|
||||
.rectangle--ver.rectangle--40 {
|
||||
--rectangle-height: 40%;
|
||||
}
|
||||
.rectangle--ver.rectangle--60 {
|
||||
--rectangle-height: 60%;
|
||||
}
|
||||
.rectangle--ver.rectangle--80 {
|
||||
--rectangle-height: 80%;
|
||||
}
|
||||
.rectangle--ver.rectangle--100 {
|
||||
--rectangle-height: 100%;
|
||||
}
|
||||
.rectangle--ver.rectangle--sm {
|
||||
--rectangle-width: 0.5rem;
|
||||
}
|
||||
.rectangle--ver.rectangle--md {
|
||||
--rectangle-width: 2rem;
|
||||
}
|
||||
.rectangle--ver.rectangle--lg {
|
||||
--rectangle-width: 4rem;
|
||||
}
|
||||
```
|
||||
|
||||
```css styles.css hidden
|
||||
body {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
.property-list {
|
||||
/* Content is center horizontally */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
|
||||
border-bottom: 1px solid #d1d5db;
|
||||
|
||||
/* Spacing */
|
||||
margin: 0;
|
||||
padding: 0.5rem 0;
|
||||
|
||||
width: 16rem;
|
||||
}
|
||||
.property-list__key {
|
||||
/* Take the remaining width */
|
||||
flex: 1;
|
||||
}
|
||||
.property-list__value {
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
```
|
||||
|
||||
```html index.html hidden
|
||||
<dl class="property-list">
|
||||
<dt class="property-list__key"><div class="rectangle rectangle--hor rectangle--sm rectangle--20"></div></dt>
|
||||
<dd class="property-list__value"><div class="circle circle--sm"></div></dd>
|
||||
</dl>
|
||||
|
||||
<dl class="property-list">
|
||||
<dt class="property-list__key"><div class="rectangle rectangle--hor rectangle--sm rectangle--60"></div></dt>
|
||||
<dd class="property-list__value"><div class="circle circle--sm"></div></dd>
|
||||
</dl>
|
||||
|
||||
<dl class="property-list">
|
||||
<dt class="property-list__key"><div class="rectangle rectangle--hor rectangle--sm rectangle--40"></div></dt>
|
||||
<dd class="property-list__value"><div class="circle circle--sm"></div></dd>
|
||||
</dl>
|
||||
|
||||
<dl class="property-list">
|
||||
<dt class="property-list__key"><div class="rectangle rectangle--hor rectangle--sm rectangle--80"></div></dt>
|
||||
<dd class="property-list__value"><div class="circle circle--sm"></div></dd>
|
||||
</dl>
|
||||
```
|
||||
</Playground>
|
Reference in New Issue
Block a user