cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation


Save Automatically?

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.

  <h2 class="full-width-borders">Full-Width Bar with Borders</h2>
  <p>This approach uses negative margins and padding to extend the background in both directions. This works great if you're using a single background color for the bar.</p>
  <p>But you can also make the Bar color different from the h2 background color by using borders, as long as you can use a solid color (RGBa values will tint the background color of the heading, and there's an issue with Safari 7, where RGBa borders display a tiny gap.)</p>
  <p>There's also a bug using super-wide borders in Chrome: You need to make them exactly 9600 or 10240px (or equivalent in ems or rems) or the positioning is off.</p>
  <p>If you want to use an RGBa value for the Bar but a different color for the heading background, you can add a <code>:before</code> <a href="https://codepen.io/parkerbennett/pen/GgqPWq" target="_blank">pseudo-element</a> with absolute positioning and a negative z-index.</p>
  <p>For more flexibility, e.g., different colors, heights, widths, gradient fades, etc., you can use <a href="https://codepen.io/parkerbennett/pen/raLaYb" target="_blank">two pseudo-elements</a>.
              /* on both */
html, body {
  overflow-x: hidden;
body {
  background: #ccc;
section {
  box-sizing: border-box; /* or not */
  margin: 0 auto;
  width: 25rem;
  background: white;
  padding: 1.5rem;
  padding-bottom: 4rem;
h2, .full-width-borders {
  /* add in section padding (1.5rem) */
  margin: 0 -601.5rem;
  /* match section padding (1.5rem) */
  padding: .25rem 1.5rem;
  background: red;
  /* border solid, not RGBa (Safari bug) */
  /* 9600px or 10240px to avoid Chrome bug */
  /* or equivalent in ems or rems (9600/16) */
  border-left: 600rem solid maroon;
  border-right: 600rem solid maroon;
  color: white;
  font-size: 1.125rem;

Loading ..................