Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="wrapper">
  <header class="container">
    <h1>Background Image Trickery</h1>
  <p>Scrolling effect with fixed background-attachment.</p>
  </header>

<div class="content container">
  <aside class="sidebar width-1v5">
    <ul>
      <li><a href="#!">list-item</a></li>
      <li><a href="#!">list-item</a></li>
      <li><a href="#!">list-item</a></li>
      <li><a href="#!">list-item</a></li>
      <li><a href="#!">list-item</a></li>
    </ul>
    <ul>
      <li><a href="#!">list-item</a></li>
      <li><a href="#!" class="active">list-item</a></li>
      <li><a href="#!">list-item</a></li>
      <li><a href="#!">list-item</a></li>
      <li><a href="#!">list-item</a></li>
    </ul>
    <ul>
      <li><a href="#!">list-item</a></li>
      <li><a href="#!">list-item</a></li>
      <li><a href="#!">list-item</a></li>
      <li><a href="#!">list-item</a></li>
      <li><a href="#!">list-item</a></li>
    </ul>
  </aside>

  <main class="main width-4v5">
  <blockquote>According to CSS, any background image that is “fixed” using <code>background-attachment: fixed;</code> is fixed with respect to the <strong>viewport</strong>-- <em>not</em> the element with which the image is associated. <i>Eric Meyer</i></blockquote>
  <p class="intro">
  For more information about <code>background-attachment: fixed</code> see the classic <a href="https://meyerweb.com/eric/css/edge/complexspiral/glassy.html">complexspiral demo</a> by Eric Meyer.</p>
  <h3>Just one background-image</h3>
  <p class="intro">
  The light-blue pattern fragments (in the tiling semi-transparent PNG background-image used here) have a 1px solid (white) border.
  </p>
  <p class="intro">
  The containing elements have different background-colors: when transparent it picks up the white <code>background-color</code> from the <code>HTML</code> element, making the pattern appear as a solid flat pattern. When the same light-blue color from the image as <code>background-color</code> is used, then this will trick the eye by making the pattern-fragments appear as white outlines.
  </p>
  <p>
  Ipsum exercitationem cum dolor aliquam nihil. Deserunt repellendus architecto veniam amet facere. Nam deleniti ipsam inventore culpa debitis? Labore rem fugiat veniam nihil nostrum hic eligendi optio? Officiis libero eos.
  </p>
  <p>
  Ipsum exercitationem cum dolor aliquam nihil. Deserunt repellendus architecto veniam amet facere. Nam deleniti ipsam inventore culpa debitis? Labore rem fugiat veniam nihil nostrum hic eligendi optio? Officiis libero eos.
  </p>
  <p>
  Ipsum exercitationem cum dolor aliquam nihil. Deserunt repellendus architecto veniam amet facere. Nam deleniti ipsam inventore culpa debitis? Labore rem fugiat veniam nihil nostrum hic eligendi optio? Officiis libero eos.
  </p>
  <p>
  Ipsum exercitationem cum dolor aliquam nihil. Deserunt repellendus architecto veniam amet facere. Nam deleniti ipsam inventore culpa debitis? Labore rem fugiat veniam nihil nostrum hic eligendi optio? Officiis libero eos.
  </p>
  <p>
  Ipsum exercitationem cum dolor aliquam nihil. Deserunt repellendus architecto veniam amet facere. Nam deleniti ipsam inventore culpa debitis? Labore rem fugiat veniam nihil nostrum hic eligendi optio? Officiis libero eos.
  </p>
  <p>
  Ipsum exercitationem cum dolor aliquam nihil. Deserunt repellendus architecto veniam amet facere. Nam deleniti ipsam inventore culpa debitis? Labore rem fugiat veniam nihil nostrum hic eligendi optio? Officiis libero eos.
  </p>
  </main>
</div>
<footer class="container"><small><a href="https://codepen.io/atelierbram/bLsjg/">on Codepen</a></small></footer>
</div> 
              
            
!

CSS

              
                *,
*:before,
*:after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  /* outline: 1px dotted salmon; */
}
$bg-image: url(https://lh4.googleusercontent.com/-A4EZf9W6K6E/U0mt4WBJb2I/AAAAAAAAA6I/D3qpuIr3NZw/s800/bg-test_codepen_200x200.png);
body,
.wrapper,
.wrapper:after {
  background: $bg-image,linear-gradient(to right,#baf2fd,#baf2fd 200px,transparent 200px,transparent 852px,#baf2fd 852px,#baf2fd);
}
.wrapper:after {
  background-color: #baf2fd;
}
.wrapper:after { content: "";
  position: absolute;
  right:0;left:0;
}
.wrapper:after {
  z-index: -2;
  top:100%;bottom:-100%;
}
header,
h3,
footer {
  background: $bg-image;
  background-color: #fff;
}
blockquote {
  background: $bg-image;
  background-color: hsla(190, 100%, 40%, .1);
  font-size: 1.5em;
  font-style: italic;
  padding: 2em 4%;
  color: #5936e2;
}
blockquote i {
  float: right;
}
.sidebar a {
  background: $bg-image;
}
.sidebar .active,
.sidebar a:hover {
  background-color: hsla(0,0%,100%,.75);
  padding-right: 0;
  padding-left: .75em;
}
body,
.wrapper,
.wrapper:after,
header,
blockquote,
h3,
.sidebar a,
footer {
   background-position: 0 0;
  background-repeat: repeat;
  background-attachment: fixed;
}

/* general styles */
html {
  background-color: #fff;
}
html,
body {
  min-height: 100%;
}
body {
  font: 100%/1.5 AvenirNext-Regular, Corbel, "Lucida Grande", "Trebuchet Ms", sans-serif;
  color: #111;
  position: relative;
}
.container {
  max-width: 54em;
  padding-left: 1.75em;
  overflow: auto;
}
h3 {
  font-size: 1.75em;
  padding: 1em 4% .5em;
}
header h1,
h3 {
  font-family: AvenirNextCondensed-DemiBold, Corbel, "Lucida Grande","Trebuchet Ms", sans-serif;
  color: #006a80;
}
header h1 {
  font-size: 2.5em;
  padding: .5em 0;
}
header h1,
header p,
footer small {
  text-indent: 23%
}
header p {
  font-size: 1.125em;
  margin-bottom: 1em;
}
.sidebar {
  padding: 2em 0 1em;
}
.sidebar ul {
  list-style: none;
  margin: 0 0 2em;
}
a {
  color: #0ac;
  text-decoration: none;
}
a:hover {
  color: #003c4d;
}
.sidebar a {
  display: block;
  padding: .25em;
  transition: all .3s;
}
.content p {
  padding: .5em 4%;
}
.content p {
  background-color: hsla(0,0%,100%,.6);
  color: #aaa;
}
.content .intro {
  color: #111;
  font-size: 1.125em;
}
p code {
  background: #ccc;
  color: #000;
  padding: 3px .5em;
  border-radius: 3px;
  font-family: Consolas, Menlo, Monaco, monospace;
  font-size: .875em;
}
footer {
  text-align: center;
}
footer a {
  padding: 2em 0 3em;
  display: block;
  color: #079;
  text-decoration: none;
}
blockquote,
i {
  font-family: AvenirNext-Italic, AvenirNext-Regular, Corbel, "Lucida Grande", "Trebuchet Ms", sans-serif;
}
em,
blockquote strong {
 font-family: AvenirNext-DemiBoldItalic, AvenirNext-Italic, Corbel, "Lucida Grande", "Trebuchet Ms", sans-serif;
}
@media (min-width:400px) {
  [class*="width-"] {
    float: left;
  }
  .width-1v5 {
    width: 20%;
  }
  .width-3v5 {
    width: 60%;
  }
  .width-4v5 {
    width: 80%;
  }
} 
@media (max-width:400px) {
  .container {
    overflow: hidden;
  }
} 
              
            
!

JS

              
                
              
            
!
999px

Console