1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-08-03 20:58:02 +02:00
Files
csslayout/contents/split-screen.mdx
2023-09-01 07:43:57 +07:00

127 lines
2.1 KiB
Plaintext

---
category: Layout
created: '2019-11-17'
description: Create a split screen with CSS flexbox
keywords: css flexbox, css layout, css split screen
thumbnail: /assets/css-layout/thumbnails/split-screen.png
title: Split screen
---
## HTML
```html index.html
<div class="split-screen">
<!-- Left content -->
<div class="split-screen__half">...</div>
<!-- Right content -->
<div class="split-screen__half">...</div>
</div>
```
## CSS
```css styles.css
.split-screen {
display: flex;
}
.split-screen__half {
flex: 1;
}
```
<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;
}
.lines {
padding: 0.25rem 0;
width: 100%;
align-items: center;
display: flex;
justify-content: center;
flex-direction: column;
}
.line {
background: #d1d5db;
height: 1px;
margin-bottom: 0.25rem;
}
.line.line--20 {
width: 20%;
}
.line.line--40 {
width: 40%;
}
.line.line--60 {
width: 60%;
}
.line.line--80 {
width: 80%;
}
.line.line--100 {
width: 100%;
}
```
```css styles.css hidden
body {
height: 24rem;
}
.split-screen {
display: flex;
/* Demo */
border: 1px solid #d1d5db;
border-radius: 0.25rem;
height: 100%;
width: 100%;
}
.split-screen__half {
flex: 1;
/* Demo */
align-items: center;
display: flex;
justify-content: center;
}
.split-screen__half:first-child {
border-right: 1px solid #d1d5db;
}
```
```html index.html hidden
<div class="split-screen">
<div class="split-screen__half">
<div class="circle circle--md"></div>
</div>
<div class="split-screen__half">
<div class="lines">
<div class="line line--20"></div>
<div class="line line--80"></div>
<div class="line line--40"></div>
<div class="line line--60"></div>
<div class="line line--20"></div>
</div>
</div>
</div>
```
</Playground>