Skip to content

Instantly share code, notes, and snippets.

@bbbbb35
Created October 20, 2021 02:33
Show Gist options
  • Save bbbbb35/faf850542bca08a540e9c1a5d1961402 to your computer and use it in GitHub Desktop.
Save bbbbb35/faf850542bca08a540e9c1a5d1961402 to your computer and use it in GitHub Desktop.
Fixed Header & Sidebar

Fixed Header & Sidebar

This is a not-so-common layout suggested by a designer friend of mine with both a header and a sidebar in recurrent positions. The actual content is well encapsulated in a "contentBox" so no internal modification will affect the general layout.

The "contentBox" itself use flexbox display to arrange its internal elements.

Feel free to ask any question. All comments welcomed.

A Pen by Aaron Machado on CodePen.

License.

<html>
<!--...-->
<head>
<meta charset="utf-8">
<title> Ghost </title>
<link rel="Stylesheet" href="css/style.css">
</head>
<body>
<div id="sidebar">
Side Content
</div>
<div id="rightSideWrapper">
<header>
Header
</header>
<div class="ContentBox"><!--. poner en minusculas.-->
<main>
Main Content
</main>
<section>
Section Content
</section>
<footer>
Footer
</footer>
</div>
</div>
</body>
</html>
*{
margin: 0px;
}
#sidebar {
/*Strictly Necessary */
position:fixed;
height: 100%;
width:30%;
margin: 0px;
/*Aesthetics*/
background: lightblue;
border-radius: 7px;
}
#rightSideWrapper {
/*Strictly Necessary */
width:70%;
float: right;
/*Aesthetics*/
background: black;
}
header {
/*Strictly Necessary */
position: fixed;
width: 70%;
height: 100px; /*Adjust the hight to your purposes*/
/*Aesthetics*/
background: lightSalmon;
border-radius: 7px;
}
.ContentBox{
margin-top: 100px; /*The height of the header*/
display:flex;
flex-flow: row wrap;
}
main, section, footer {
/*Aesthetics*/
background: lightgray;
border-radius: 7px;
margin: 5px;
padding: 20px;
}
main {
/*Strictly Necessary */
height: 400px;
order: 1;
flex: 0 1 100%;
}
section {
/*Strictly Necessary */
height: 400px;
order: 2;
flex: 0 1 100%;
}
footer {
/*Strictly Necessary */
height: 100px;
order: 3;
flex: 0 1 100%;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment