Add a simplified sidebar using negative margins for bleed
This commit is contained in:
parent
76e18bb922
commit
4e55653564
2 changed files with 178 additions and 0 deletions
46
src/sidebar-2/index.html
Normal file
46
src/sidebar-2/index.html
Normal file
|
@ -0,0 +1,46 @@
|
|||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="./index.scss" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="hero" id="hero">
|
||||
<div class="details-wrapper" id="details">
|
||||
<div class="details">
|
||||
<small>Breadcrumb</small>
|
||||
<h1>Title</h1>
|
||||
<p>Details</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<main>
|
||||
<div class="spacer"></div>
|
||||
<div class="content-wrapper">
|
||||
<p>Content</p>
|
||||
<img src="https://placehold.co/2000x200" />
|
||||
<img src="https://placehold.co/2000x200" class="inset" />
|
||||
<img src="https://placehold.co/2000x200" class="bleed" />
|
||||
<p>Content</p>
|
||||
<p>Content</p>
|
||||
<p>Content</p>
|
||||
<p>Content</p>
|
||||
<p>Content</p>
|
||||
<p>Content</p>
|
||||
<p>Content</p>
|
||||
<p>Content</p>
|
||||
<p>Content</p>
|
||||
<p>Content</p>
|
||||
<p>Content</p>
|
||||
<p>Content</p>
|
||||
<p>Content</p>
|
||||
<p>Content</p>
|
||||
<p>Content</p>
|
||||
</div>
|
||||
<div class="sidebar">
|
||||
<div class="sidebar-inner">
|
||||
<p>Sidebar</p>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
132
src/sidebar-2/index.scss
Normal file
132
src/sidebar-2/index.scss
Normal file
|
@ -0,0 +1,132 @@
|
|||
@import "normalize.css";
|
||||
|
||||
body,
|
||||
html {
|
||||
height: 100%;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
$content-width: 80ch;
|
||||
$content-padding: 16px;
|
||||
|
||||
$bleed-ratio: 0.1;
|
||||
$details-bg: black;
|
||||
$details-padding: $content-padding;
|
||||
|
||||
$bleed-size: $content-width * $bleed-ratio;
|
||||
|
||||
.hero {
|
||||
height: 50vh;
|
||||
background-color: red;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
|
||||
.details-wrapper {
|
||||
background-color: transparentize($details-bg, 0.6);
|
||||
color: white;
|
||||
line-height: 1;
|
||||
width: calc(100% - ($details-padding * 2));
|
||||
padding: 0 $details-padding;
|
||||
}
|
||||
|
||||
.details {
|
||||
width: $content-width;
|
||||
max-width: 100%;
|
||||
margin: 1rem auto;
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
margin-bottom: 0.75rem;
|
||||
margin-top: 0.5rem;
|
||||
font-size: 3.5rem;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.spacer {
|
||||
flex-grow: 1;
|
||||
flex-shrink: 10;
|
||||
flex-basis: 200px;
|
||||
}
|
||||
|
||||
.content-wrapper {
|
||||
width: $content-width;
|
||||
max-width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-left: $bleed-size;
|
||||
margin-right: $bleed-size;
|
||||
|
||||
.bleed {
|
||||
margin-left: -$bleed-size;
|
||||
margin-right: -$bleed-size;
|
||||
}
|
||||
|
||||
.inset {
|
||||
margin-left: $bleed-size;
|
||||
margin-right: $bleed-size;
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
flex-grow: 1;
|
||||
flex-shrink: 10;
|
||||
flex-basis: 200px;
|
||||
min-width: 300px;
|
||||
background-color: orange;
|
||||
|
||||
.sidebar-inner {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1250px) {
|
||||
main {
|
||||
flex-direction: column-reverse;
|
||||
align-items: center;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.spacer {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
flex-basis: unset;
|
||||
width: $content-width;
|
||||
max-width: 100%;
|
||||
|
||||
.sidebar-inner {
|
||||
position: unset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 915px) {
|
||||
.bleed {
|
||||
margin-left: -1rem !important;
|
||||
margin-right: -1rem !important;
|
||||
}
|
||||
.inset {
|
||||
margin-left: 1rem !important;
|
||||
margin-right: 1rem !important;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@media (max-width: 400px) {
|
||||
.sidebar {
|
||||
display: none;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue