Layout

In this example below you will see how to do a Layout with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by prebla, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright prebla ©
  • HTML
  • CSS
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>Layout</title>
  
  
  
      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  <!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Seven Bridges</title>
</head>
<body>
    <header id="header"><nav id="navigation">header</nav></header>
  
    <main id="main">
        <section id="content">
            <div class="sbg-layout sbg-layout-vertical">
                blaaad
            </div>
        </section>

        <footer id="footer">footer</footer>
    </main>
</body>
</html>
  
  

</body>

</html>

/*Downloaded from https://www.codeseek.co/prebla/layout-mAZZXX */
#navigation {
  background-color: #3B3F42;
}

#footer {
  color: #777;
  background-color: #f9f9f9;
  border-top: 1px solid #c7c7c7;
}

/**
 * Layout classes
 *
 * There are some workarounds that we had to implement in order to make the flexbox
 * behave the same in all the major browsers:
 *
 * @see: http://stackoverflow.com/questions/28636832/firefox-overflow-y-not-working-with-nested-flexbox
 * @see: https://github.com/philipwalton/flexbugs
 */
html,
body {
  width: 100vw;
  height: 100vh;
}

body {
  display: -webkit-box;
  display: -webkit-flex;
  display: -moz-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-direction: normal;
  -webkit-box-orient: vertical;
  -webkit-flex-direction: column;
  -moz-flex-direction: column;
  -ms-flex-direction: column;
  flex-direction: column;
  overflow: hidden;
}

#header {
  display: -webkit-box;
  display: -webkit-flex;
  display: -moz-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-direction: normal;
  -webkit-box-orient: vertical;
  -webkit-flex-direction: column;
  -moz-flex-direction: column;
  -ms-flex-direction: column;
  flex-direction: column;
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  -moz-box-flex: 0;
  -moz-flex: 0 0 auto;
  -ms-flex: 0 0 auto;
  flex: 0 0 auto;
}
#header:empty, #header > :empty {
  display: none;
}

#announcements {
  -webkit-box-ordinal-group: 1;
  -webkit-order: 0;
  -moz-order: 0;
  -ms-flex-order: 0;
  order: 0;
}

#notifications {
  -webkit-box-ordinal-group: 3;
  -webkit-order: 2;
  -moz-order: 2;
  -ms-flex-order: 2;
  order: 2;
}

#navigation {
  height: 3em;
  -webkit-box-ordinal-group: 2;
  -webkit-order: 1;
  -moz-order: 1;
  -ms-flex-order: 1;
  order: 1;
}

#main {
  -webkit-box-flex: 1;
  -webkit-flex: 1 0 auto;
  -moz-box-flex: 1;
  -moz-flex: 1 0 auto;
  -ms-flex: 1 0 auto;
  flex: 1 0 auto;
  display: -webkit-box;
  display: -webkit-flex;
  display: -moz-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-direction: normal;
  -webkit-box-orient: vertical;
  -webkit-flex-direction: column;
  -moz-flex-direction: column;
  -ms-flex-direction: column;
  flex-direction: column;
  height: 0;
  overflow: auto;
}

#content {
  -webkit-box-flex: 1;
  -webkit-flex: 1 0 auto;
  -moz-box-flex: 1;
  -moz-flex: 1 0 auto;
  -ms-flex: 1 0 auto;
  flex: 1 0 auto;
  display: -webkit-box;
  display: -webkit-flex;
  display: -moz-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-direction: normal;
  -webkit-box-orient: vertical;
  -webkit-flex-direction: column;
  -moz-flex-direction: column;
  -ms-flex-direction: column;
  flex-direction: column;
  -webkit-box-align: stretch;
  -ms-flex-align: stretch;
  -webkit-align-items: stretch;
  -moz-align-items: stretch;
  align-items: stretch;
  -webkit-align-content: stretch;
  -moz-align-content: stretch;
  -ms-flex-line-pack: stretch;
  align-content: stretch;
  margin: 0;
  padding: 0;
  overflow: visible;
}

#footer {
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  -moz-box-flex: 0;
  -moz-flex: 0 0 auto;
  -ms-flex: 0 0 auto;
  flex: 0 0 auto;
  padding: 0.75em 1.125em;
}
#footer:empty, #footer > :empty {
  display: none;
}
#footer .sbg-button {
  margin: 0;
}

/* Layout classes */
.sbg-layout {
  -webkit-box-flex: 1;
  -webkit-flex: 1 0 auto;
  -moz-box-flex: 1;
  -moz-flex: 1 0 auto;
  -ms-flex: 1 0 auto;
  flex: 1 0 auto;
  display: -webkit-box;
  display: -webkit-flex;
  display: -moz-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-direction: normal;
  -webkit-box-orient: vertical;
  -webkit-flex-direction: column;
  -moz-flex-direction: column;
  -ms-flex-direction: column;
  flex-direction: column;
  -webkit-box-align: stretch;
  -ms-flex-align: stretch;
  -webkit-align-items: stretch;
  -moz-align-items: stretch;
  align-items: stretch;
  -webkit-align-content: stretch;
  -moz-align-content: stretch;
  -ms-flex-line-pack: stretch;
  align-content: stretch;
}

/* Layout modifiers */
.sbg-layout--vertical {
  -webkit-box-direction: normal;
  -webkit-box-orient: vertical;
  -webkit-flex-direction: column;
  -moz-flex-direction: column;
  -ms-flex-direction: column;
  flex-direction: column;
  min-height: 0;
}

.sbg-layout--horizontal {
  -webkit-box-direction: normal;
  -webkit-box-orient: horizontal;
  -webkit-flex-direction: row;
  -moz-flex-direction: row;
  -ms-flex-direction: row;
  flex-direction: row;
  min-width: 0;
}

.sbg-layout--centered, .sbg-layout__content--centered {
  -webkit-align-self: center;
  -moz-align-self: center;
  -ms-flex-item-align: center;
  align-self: center;
  margin: 0 auto;
  max-width: 960px;
}

.sbg-layout--wrapper {
  -webkit-box-flex: 1;
  -webkit-flex: 1 0 auto;
  -moz-box-flex: 1;
  -moz-flex: 1 0 auto;
  -ms-flex: 1 0 auto;
  flex: 1 0 auto;
  display: -webkit-box;
  display: -webkit-flex;
  display: -moz-flex;
  display: -ms-flexbox;
  display: flex;
  height: 0;
  min-height: 0;
  overflow: hidden;
}

.sbg-layout--scrollable,
.sbg-layout.sbg-layout--scrollable,
.sbg-layout__content.sbg-layout--scrollable {
  overflow: auto;
}

.sbg-layout--cutoff,
.sbg-layout.sbg-layout--cutoff,
.sbg-layout__content.sbg-layout--cutoff {
  overflow: hidden;
}

.sbg-layout--overflow,
.sbg-layout.sbg-layout--overflow,
.sbg-layout__content.sbg-layout--overflow {
  overflow: visible;
}

/* Layout blocks */
.sbg-layout__header {
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  -moz-box-flex: 0;
  -moz-flex: 0 0 auto;
  -ms-flex: 0 0 auto;
  flex: 0 0 auto;
}

.sbg-layout__sidebar {
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  -moz-box-flex: 0;
  -moz-flex: 0 0 auto;
  -ms-flex: 0 0 auto;
  flex: 0 0 auto;
  -webkit-box-ordinal-group: 0;
  -webkit-order: -1;
  -moz-order: -1;
  -ms-flex-order: -1;
  order: -1;
  width: 300px;
}

.sbg-layout--left,
.sbg-layout__sidebar--left {
  -webkit-box-ordinal-group: 0;
  -webkit-order: -1;
  -moz-order: -1;
  -ms-flex-order: -1;
  order: -1;
}

.sbg-layout--right,
.sbg-layout__sidebar--right {
  -webkit-box-ordinal-group: 2;
  -webkit-order: 1;
  -moz-order: 1;
  -ms-flex-order: 1;
  order: 1;
}

.sbg-layout__content {
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 auto;
  -moz-box-flex: 1;
  -moz-flex: 1 1 auto;
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
  overflow: auto;
}

/* Layout content modifiers */
.sbg-layout__content--half {
  width: 50%;
  max-width: 50%;
}

.sbg-layout__content--third {
  width: 33%;
  max-width: 33%;
}

.sbg-layout__content--quarter {
  width: 25%;
  max-width: 25%;
}

Comments