mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-16 19:14:08 +02:00
Add CSS code for layout patterns
This commit is contained in:
@@ -22,23 +22,9 @@ const Details: React.FC<{}> = () => {
|
||||
<div className='p-8 pb-20'>
|
||||
<BrowserFrame
|
||||
html={`
|
||||
<div style="
|
||||
display: flex;
|
||||
|
||||
/* Put a card in the next row when previous cards take all width */
|
||||
flex-wrap: wrap;
|
||||
|
||||
margin-left: -8px;
|
||||
margin-right: -8px;
|
||||
">
|
||||
<div class="container">
|
||||
<!-- A card with given width -->
|
||||
<div style="
|
||||
/* There will be 4 cards per row */
|
||||
flex-basis: 25%;
|
||||
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
">
|
||||
<div class="card">
|
||||
...
|
||||
</div>
|
||||
|
||||
@@ -46,7 +32,24 @@ html={`
|
||||
...
|
||||
</div>
|
||||
`}
|
||||
css={``}
|
||||
css={`
|
||||
.container {
|
||||
display: flex;
|
||||
|
||||
/* Put a card in the next row when previous cards take all width */
|
||||
flex-wrap: wrap;
|
||||
|
||||
margin-left: -8px;
|
||||
margin-right: -8px;
|
||||
}
|
||||
.card {
|
||||
/* There will be 4 cards per row */
|
||||
flex-basis: 25%;
|
||||
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
}
|
||||
`}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
|
@@ -22,45 +22,49 @@ const Details: React.FC<{}> = () => {
|
||||
<div className='p-8 pb-20'>
|
||||
<BrowserFrame
|
||||
html={`
|
||||
<div style="
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
">
|
||||
<div class="container">
|
||||
<header>
|
||||
...
|
||||
</header>
|
||||
<main style="
|
||||
/* Take the remaining height */
|
||||
flex-grow: 1;
|
||||
|
||||
/* Layout the left sidebar, main content and right sidebar */
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
">
|
||||
<main class="main">
|
||||
<!-- Left sidebar -->
|
||||
<aside style="
|
||||
width: 25%;
|
||||
">...</aside>
|
||||
<aside class="left">...</aside>
|
||||
|
||||
<!-- Main content -->
|
||||
<article style="
|
||||
/* Take the remaining width */
|
||||
flex-grow: 1;
|
||||
">
|
||||
...
|
||||
</article>
|
||||
<article class="middle">...</article>
|
||||
|
||||
<!-- Right sidebar -->
|
||||
<nav style="
|
||||
width: 20%;
|
||||
">...</nav>
|
||||
<nav class="right">...</nav>
|
||||
</main>
|
||||
<footer>
|
||||
...
|
||||
</footer>
|
||||
</div>
|
||||
`}
|
||||
css={``}
|
||||
css={`
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.main {
|
||||
/* Take the remaining height */
|
||||
flex-grow: 1;
|
||||
|
||||
/* Layout the left sidebar, main content and right sidebar */
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
.left {
|
||||
width: 25%;
|
||||
}
|
||||
.middle {
|
||||
/* Take the remaining width */
|
||||
flex-grow: 1;
|
||||
}
|
||||
.right {
|
||||
width: 20%;
|
||||
}
|
||||
`}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
|
@@ -22,25 +22,14 @@ const Details: React.FC<{}> = () => {
|
||||
<div className='p-8 pb-20'>
|
||||
<BrowserFrame
|
||||
html={`
|
||||
<div style="display: flex;">
|
||||
<div class="container">
|
||||
<!-- Column -->
|
||||
<div style="
|
||||
flex: 1;
|
||||
/* Space between columns */
|
||||
margin: 0 8px;
|
||||
|
||||
/* Layout each column */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
">
|
||||
<div class="column">
|
||||
<!-- Cover -->
|
||||
...
|
||||
|
||||
<!-- Content -->
|
||||
<div style="
|
||||
/* Take available height */
|
||||
flex: 1;
|
||||
">
|
||||
<div class="content">
|
||||
...
|
||||
</div>
|
||||
|
||||
@@ -52,7 +41,24 @@ html={`
|
||||
...
|
||||
</div>
|
||||
`}
|
||||
css={``}
|
||||
css={`
|
||||
.container {
|
||||
display: flex;
|
||||
}
|
||||
.column {
|
||||
flex: 1;
|
||||
/* Space between columns */
|
||||
margin: 0 8px;
|
||||
|
||||
/* Layout each column */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.content {
|
||||
/* Take available height */
|
||||
flex: 1;
|
||||
}
|
||||
`}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
|
@@ -22,25 +22,33 @@ const Details: React.FC<{}> = () => {
|
||||
<div style={{ lineHeight: 1.5, marginBottom: '16px' }}>Try to scroll the main content!</div>
|
||||
<BrowserFrame
|
||||
html={`
|
||||
<div style="display: flex;">
|
||||
<div class="container">
|
||||
<!-- Sidebar -->
|
||||
<aside style="width: 30%;">
|
||||
<aside class="sidebar">
|
||||
...
|
||||
</aside>
|
||||
|
||||
<!-- Main -->
|
||||
<main style="
|
||||
/* Take the remaining width */
|
||||
flex: 1;
|
||||
|
||||
/* Make it scrollable */
|
||||
overflow: auto;
|
||||
">
|
||||
<main class="main">
|
||||
...
|
||||
</main>
|
||||
</div>
|
||||
`}
|
||||
css={``}
|
||||
css={`
|
||||
.container {
|
||||
display: flex;
|
||||
}
|
||||
.sidebar {
|
||||
width: 30%;
|
||||
}
|
||||
.main {
|
||||
/* Take the remaining width */
|
||||
flex: 1;
|
||||
|
||||
/* Make it scrollable */
|
||||
overflow: auto;
|
||||
}
|
||||
`}
|
||||
>
|
||||
<div style={{ display: 'flex', height: '100%' }}>
|
||||
<div
|
||||
|
@@ -23,30 +23,36 @@ const Details: React.FC<{}> = () => {
|
||||
<BrowserFrame
|
||||
html={`
|
||||
<!-- Row -->
|
||||
<div style="
|
||||
display: flex;
|
||||
|
||||
margin-left: -8px;
|
||||
margin-right: -8px;
|
||||
">
|
||||
<div class="row">
|
||||
<!--Cell with given width. Replace 25% with whatever you want -->
|
||||
<div style="
|
||||
flex: 0 0 25%;
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
">25%</div>
|
||||
<div class="cell width-1/4">25%</div>
|
||||
|
||||
<!-- Cell that takes remaining width -->
|
||||
<div style="
|
||||
flex: 1;
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
">
|
||||
<div class="cell width-fill">
|
||||
...
|
||||
</div>
|
||||
</div>
|
||||
`}
|
||||
css={``}
|
||||
css={`
|
||||
.row {
|
||||
display: flex;
|
||||
|
||||
margin-left: -8px;
|
||||
margin-right: -8px;
|
||||
}
|
||||
.cell {
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
}
|
||||
|
||||
/* Cell with given width. Replace 25% with whatever you want */
|
||||
.cell.width-1/4 {
|
||||
flex: 0 0 25%;
|
||||
}
|
||||
.cell.width-fill {
|
||||
flex: 1;
|
||||
}
|
||||
`}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
|
@@ -23,19 +23,26 @@ const Details: React.FC<{}> = () => {
|
||||
<div className='p-8 pb-20'>
|
||||
<BrowserFrame
|
||||
html={`
|
||||
<div style="display: flex;">
|
||||
<div class="container">
|
||||
<!-- Left content -->
|
||||
<div style="flex: 1;">
|
||||
<div class="half">
|
||||
...
|
||||
</div>
|
||||
|
||||
<!-- Right content -->
|
||||
<div style="flex: 1;">
|
||||
<div class="half">
|
||||
...
|
||||
</div>
|
||||
</div>
|
||||
`}
|
||||
css={``}
|
||||
css={`
|
||||
.container {
|
||||
display: flex;
|
||||
}
|
||||
.half {
|
||||
flex: 1;
|
||||
}
|
||||
`}
|
||||
>
|
||||
<div style={{ display: 'flex', height: '100%' }}>
|
||||
<div
|
||||
|
@@ -25,23 +25,32 @@ const Details: React.FC<{}> = () => {
|
||||
</div>
|
||||
<BrowserFrame
|
||||
html={`
|
||||
<div style="
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
">
|
||||
<header style="flex-shrink: 0;">
|
||||
<div class="container">
|
||||
<header class="header">
|
||||
...
|
||||
</header>
|
||||
<main style="flex-grow: 1;">
|
||||
<main class="main">
|
||||
...
|
||||
</main>
|
||||
<footer style="flex-shrink: 0;">
|
||||
<footer class="footer">
|
||||
...
|
||||
</footer>
|
||||
</div>
|
||||
`}
|
||||
css={``}
|
||||
css={`
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
.header,
|
||||
.footer {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.main {
|
||||
flex-grow: 1;
|
||||
}
|
||||
`}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
|
@@ -27,11 +27,7 @@ const Details: React.FC<{}> = () => {
|
||||
<BrowserFrame
|
||||
html={`
|
||||
<div>
|
||||
<header style="
|
||||
/* Stick to the top */
|
||||
position: sticky;
|
||||
top: 0;
|
||||
">
|
||||
<header class="header">
|
||||
...
|
||||
</header>
|
||||
<main>
|
||||
@@ -39,7 +35,13 @@ html={`
|
||||
</main>
|
||||
</div>
|
||||
`}
|
||||
css={``}
|
||||
css={`
|
||||
.header {
|
||||
/* Stick to the top */
|
||||
position: sticky;
|
||||
top: 0;
|
||||
}
|
||||
`}
|
||||
>
|
||||
<div>
|
||||
<div
|
||||
|
@@ -24,19 +24,8 @@ const Details: React.FC<{}> = () => {
|
||||
</div>
|
||||
<BrowserFrame
|
||||
html={`
|
||||
<div style="
|
||||
height: 100%;
|
||||
overflow: scroll;
|
||||
">
|
||||
<section style="
|
||||
/* Take full size */
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
||||
/* Stick to the top */
|
||||
position: sticky;
|
||||
top: 0;
|
||||
">
|
||||
<div class="container">
|
||||
<section class="section">
|
||||
...
|
||||
</section>
|
||||
|
||||
@@ -44,7 +33,21 @@ html={`
|
||||
...
|
||||
</div>
|
||||
`}
|
||||
css={``}
|
||||
css={`
|
||||
.container {
|
||||
height: 100%;
|
||||
overflow: scroll;
|
||||
}
|
||||
.section {
|
||||
/* Take full size */
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
||||
/* Stick to the top */
|
||||
position: sticky;
|
||||
top: 0;
|
||||
}
|
||||
`}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
|
Reference in New Issue
Block a user