mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-10-24 19:26:26 +02:00
`overflow: auto` is usually a better choice than `overflow: scroll` when you want to make component scrollable. The only difference is that with `auto` you do not see the scrollbar when there's nothing to scroll.
69 lines
2.6 KiB
TypeScript
69 lines
2.6 KiB
TypeScript
import React from 'react';
|
|
|
|
import DetailsLayout from '../../layouts/DetailsLayout';
|
|
import Block from '../../placeholders/Block';
|
|
import BrowserFrame from '../../placeholders/BrowserFrame';
|
|
|
|
const Details: React.FC<{}> = () => {
|
|
return (
|
|
<DetailsLayout title="Sidebar">
|
|
<div style={{ padding: '64px 32px' }}>
|
|
<div style={{ lineHeight: 1.5, marginBottom: '16px' }}>Try to scroll the main content!</div>
|
|
<BrowserFrame
|
|
content={(
|
|
<div style={{ display: 'flex', height: '100%' }}>
|
|
<div
|
|
style={{
|
|
borderRight: '1px solid rgba(0, 0, 0, 0.3)',
|
|
display: 'flex',
|
|
flexDirection: 'column',
|
|
justifyContent: 'flex-end',
|
|
padding: '16px',
|
|
width: '30%',
|
|
}}
|
|
>
|
|
<div style={{ marginBottom: '16px' }}><Block numberOfBlocks={5} /></div>
|
|
<div style={{ width: '80%' }}><Block numberOfBlocks={4} /></div>
|
|
</div>
|
|
<div
|
|
style={{
|
|
flex: 1,
|
|
overflow: 'auto',
|
|
padding: '16px',
|
|
}}
|
|
>
|
|
<div style={{ marginBottom: '32px' }}><Block numberOfBlocks={20} /></div>
|
|
<div style={{ marginBottom: '32px' }}><Block numberOfBlocks={20} /></div>
|
|
<div style={{ marginBottom: '32px' }}><Block numberOfBlocks={20} /></div>
|
|
<div style={{ marginBottom: '32px' }}><Block numberOfBlocks={20} /></div>
|
|
<div style={{ width: '80%' }}><Block numberOfBlocks={10} /></div>
|
|
</div>
|
|
</div>
|
|
)}
|
|
source={`
|
|
<div style="display: flex;">
|
|
<!-- Sidebar -->
|
|
<aside style="width: 30%;">
|
|
...
|
|
</aside>
|
|
|
|
<!-- Main -->
|
|
<main style="
|
|
/* Take the remaining width */
|
|
flex: 1;
|
|
|
|
/* Make it scrollable */
|
|
overflow: auto;
|
|
">
|
|
...
|
|
</main>
|
|
</div>
|
|
`}
|
|
/>
|
|
</div>
|
|
</DetailsLayout>
|
|
);
|
|
};
|
|
|
|
export default Details;
|