Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

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

              
                <article class="wrapper">
  <h1 class="fluid-type">Full bleed CSS Utility</h1>
  <p>You can break an element out of its container while maintaining its flow within that container using <code>margin</code> and <code>transform</code>. There’s two examples, both using the <code>.full-bleed</code> utility to achieve this affect.</p> 
  <p>You can read more in Piccalilli #2’s article and subscribe for more like this.</p>
  <aside class="[ full-bleed ] [ promo ]">
    <div class="wrapper">
      <h2 class="fluid-type">Some aside content that is full bleed</h2>
      <p>This element contains the full bleed utility, so it's broken out of the article’s horizontal bounds.</p>
    </div>
  </aside>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla. Nulla vitae elit libero, a pharetra augue. Curabitur blandit tempus porttitor.</p>
  <h2 class="fluid-type">Cras mattis consectetur purus sit amet fermentum.</h2>
  <p>Nulla vitae elit libero, a pharetra augue. Maecenas faucibus mollis interdum. Curabitur blandit tempus porttitor. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Etiam porta sem malesuada magna mollis euismod. Cras mattis consectetur purus sit amet fermentum. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.</p>
  <figure class="[ full-bleed ] [ feature-figure ]">
    <img 
      src="https://source.unsplash.com/e_DmszdpETY/1200x600" 
      srcset="https://source.unsplash.com/e_DmszdpETY/2400x1200 2400w,
              https://source.unsplash.com/e_DmszdpETY/1400x700 1400w,
              https://source.unsplash.com/e_DmszdpETY/1200x600 1200w,
              https://source.unsplash.com/e_DmszdpETY/800x400 800w,
              https://source.unsplash.com/e_DmszdpETY/600x300 600w"
      sizes="100vw"
      alt="low-angle photography of trees" 
    />
    <figcaption>A full bleed image, using the same utility - Photo by Jonathan Borba on Unsplash</figcaption>
  </figure>
  <p>Etiam porta sem malesuada magna mollis euismod. Maecenas sed diam eget risus varius blandit sit amet non magna. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
  <p>Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas faucibus mollis interdum. Donec id elit non mi porta gravida at eget metus. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed posuere consectetur est at lobortis.</p>
</article>
              
            
!

CSS

              
                /**
 * FULL BLEED
 *
 * Add this class to an element to make it fill the width of the screen 
 * and sit horizontally central
 */
.full-bleed {
  width: 100vw;
  margin-left: 50%;
  transform: translateX(-50%);
}









/* EVERYTHING BELOW THIS LINE IS FOR PRESENTATION ONLY */

/* A promo presentational component */
.promo {
  color: #ffffff;
  background-color: #8C2ED7;
  background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%238003e4' fill-opacity='0.4' fill-rule='evenodd'%3E%3Ccircle cx='3' cy='3' r='3'/%3E%3Ccircle cx='13' cy='13' r='3'/%3E%3C/g%3E%3C/svg%3E");
  padding: 3rem 2rem;
  box-shadow: 0 0 20px hsla(273, 79%, 19%, 0.5);  
}

.promo__inner {
  max-width: 50rem;
  margin: 0 auto;
}

.promo h2.fluid-type {
  --fluid-type-min-size: 2;
  --fluid-type-max-size: 3.5;
  
  font-family: 'Source Sans Pro', sans-serif;
  font-weight: 700;
  margin: 0;
  max-width: 20ch;
}

.promo p {
  font-size: 1.8rem;
  font-weight: 300;
}


/* A feature figure presentational component */
.feature-figure img {
  width: 100%;
  box-shadow: 0 0 20px hsl(0, 0%, 0%, 0.2);
}

.feature-figure figcaption {
  text-align: center;
  font-style: italic;
  margin-top: 0.6rem;
}

@supports (object-fit: cover) {
  .feature-figure img {
    max-height: 25rem;
    object-fit: cover;
  }
}





* {
  box-sizing: border-box;
}

/* Shared wrapper */
.wrapper {
  max-width: 50rem;
  margin-left: auto;
  margin-right: auto;
}


/*
* GENERAL HTML STYLES
*/
body {
  font-family: 'Source Sans Pro', sans-serif;
  background: #f3f3f3;
  color: #141414;
  padding: 1rem 2rem 4rem 2rem;
  line-height: 1.4;
  overflow-x: hidden;
}

h1, h2, h3 {
  line-height: 1.2;
}

p {
  font-size: 1.25rem;
  max-width: 75ch;
}

h1, h2, h3, blockquote {
  font-family: 'Libre Baskerville', serif;
}

code {
  font-size: 1.2em;
  font-weight: bold;
  padding: 0 0.4rem;
  color: #8C2ED7;
}

a {
  color: #8C2ED7;
}

article > * + * {
  margin-top: 1.8em;
}



/**
 * FLUID TYPE
 *
 * Scale text based on viewport and the following variables. Props should be unitless, but will be converted
 * to REM units. E.G '1' will be converted to '1rem'
 *
 * --fluid-type-min-size: The smallest font size. Default 1
 * --fluid-type-max-size: The largest font size: Default 2
 * --fluid-type-min-screen: The smallest viewport size that this works for: Default 20
 * --fluid-type-max-screen: The largest viewport size that this works for: Default 88
 */
.fluid-type {
  --fluid-type-min-size: 1;
  --fluid-type-max-size: 2;
  --fluid-type-min-screen: 20;
  --fluid-type-max-screen: 88;

  /* We multiply by 1rem to essentially stick a rem unit to a number. */
  font-size: calc(
    (var(--fluid-type-min-size) * 1rem) + (var(--fluid-type-max-size) - var(--fluid-type-min-size)) *
      (100vw - (var(--fluid-type-min-screen) * 1rem)) /
      (var(--fluid-type-max-screen) - var(--fluid-type-min-screen))
  );
}

/*
* SET LOCKS ON ELEMENTS
*/
h1.fluid-type {
  --fluid-type-min-size: 2;
  --fluid-type-max-size: 4;
}

h2.fluid-type {
  --fluid-type-min-size: 1.5;
  --fluid-type-max-size: 2.2;
}
              
            
!

JS

              
                
              
            
!
999px

Console