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

              
                //- Trying to recreate Web Stories in HTML+CSS
label(for="stories-view-toggle") Storify
input(type="checkbox" id="stories-view-toggle")
main
  section#first
    article
      h2 Sitemaps
      p Placeholder text can be a great way to speed up form completion, but it can also have a downside. This article looks at the effects of placeholder text on user accuracy when filling out forms.
    nav
      a(rel="next" href="#second" aria-label="Next")
  section#second
    article   
      h2 Muffin
      p Shortbread gummies jelly beans bonbon dragée.
    nav
      a(rel="prev" href="#first" aria-label="Previous")
      a(rel="next" href="#third" aria-label="Next")
  section#third
    article
      h2 Brownies
      p Gingerbread pastry jelly pie croissant jujubes shortbread.
    nav
      a(rel="prev" href="#second" aria-label="Previous")
      
              
            
!

CSS

              
                :root {
  --hue: 201;
  --color-dark: hsl(var(--hue), 5%, 10%);
  --color-dark-glare: hsl(var(--hue), 5%, 43.5%);
  --color-light: hsl(var(--hue), 5%, 100%);
  --color-light-glare: hsl(var(--hue), 56%, 98%);
  --color-primary: hsl(var(--hue), 96%, 32%);
  --color-primary-glare: hsl(var(--hue), 56%, 90%);
  --color-secondary: hsl(348, 69%, 57%);
  --color-secondary-glare: hsl(335, 62%, 89%);
  --space-xs: clamp(0.75rem, 0.69rem + 0.29vw, 0.9375rem);
  --space-s: clamp(1rem, 0.92rem + 0.39vw, 1.25rem);
  --space-m: clamp(1.5rem, 1.38rem + 0.58vw, 1.875rem);
  --space-l: clamp(2rem, 1.84rem + 0.78vw, 2.5rem);
  --space-xl: clamp(3rem, 2.77rem + 1.17vw, 3.75rem);
  --space-2xl: clamp(4rem, 3.69rem + 1.55vw, 5rem);
  --space-3xl: clamp(6rem, 5.53rem + 2.33vw, 7.5rem);
  --space-xs-s: clamp(0.75rem, 0.59rem + 0.78vw, 1.25rem);
  --space-s-m: clamp(1rem, 0.73rem + 1.36vw, 1.875rem);
  --space-m-l: clamp(1.5rem, 1.19rem + 1.55vw, 2.5rem);
  --space-l-xl: clamp(2rem, 1.46rem + 2.72vw, 3.75rem);
  --space-l-2xl: clamp(2rem, 1.07rem + 4.66vw, 5rem);
  --space-xl-2xl: clamp(3rem, 2.38rem + 3.11vw, 5rem);
  --space-2xl-3xl: clamp(4rem, 2.91rem + 5.44vw, 7.5rem);
  /* @link https://utopia.fyi/type/calculator?c=320,14,1.2,1920,20,1.25,0,0,&s=0.75|0.5|0.25,1.5|2|3|4|6,s-l&g=s,l,xl,12 */

  --size-step-0: clamp(0.88rem, calc(0.8rem + 0.38vw), 1.25rem);

  /* System font: https://modernfontstacks.com/ */
  --font-base: ui-rounded, "Hiragino Maru Gothic ProN", Quicksand, Comfortaa,
    Manjari, "Arial Rounded MT Bold", Calibri, source-sans-pro, sans-serif;
  --font-display: "Charter", "Bitstream Charter", "Sitka Text", "Cambria", serif;
  --font-mono: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas,
    "DejaVu Sans Mono", monospace;

  --gutter: var(--space-m-l);
  --border-radius: 0.35rem;
  --measure: 60ch; /* ideal line length according to research */
  --story-width: 300px;
  --story-height: 380px;
  --story-padding: 1.5rem;
  --page-top: 3rem;
}

body {
  /*
--full: minmax(var(--gutter), 1fr);
  --content: min(var(--content-size, var(--measure)), 100% - var(--gutter) * 2);
  --popout: minmax(0, var(--popout-size, var(--space-l, 2rem)));
  --feature: minmax(0, var(--feature-size, var(--space-2xl, 4rem)));

  display: grid;
  grid-template-columns:
    [full-start] var(--full)
    [feature-start] var(--feature)
    [popout-start] var(--popout)
    [content-start] var(--content) [content-end]
    var(--popout) [popout-end]
    var(--feature) [feature-end]
    var(--full) [full-end];
  
  */
}

/* Lowering the specificity here with :where */
:where(.content > *) {
  grid-column: content;
}

.full {
  grid-column: full;
}
.popout {
  grid-column: popout;
}
.feature {
  grid-column: feature;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--page-top);
}

body {
  font-family: var(--font-display);
  padding-top: var(--page-top);
}
h2{
  font-family: var(--font-base);
}
input:checked ~ main {
  margin: auto;
  display: grid;
  grid-auto-flow: column;
  gap: 1rem;
  height: calc(var(--story-height) + 1rem);
  max-width: var(--story-width);
  overflow-y: auto;
  box-shadow: 0 20px 50px 0 rgba(0, 0, 0, 0.2);

  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
}
input:checked ~ main > section {
  scroll-snap-align: center;
  scroll-snap-stop: always;
  box-sizing: border-box;
  border-radius: var(--border-radius);
  width: var(--story-width);

  display: grid;
  grid-template-columns:
    [full-start] var(--story-padding)
    [content-start] auto [content-end]
    var(--story-padding) [full-end];
  grid-template-rows: 1fr;
}

input:checked ~ main > section > nav {
  grid-column: full;
  grid-row: 1/-1;
  display: grid;
  grid-template-columns: var(--story-padding) auto var(--story-padding);
}

input:checked ~ main > section > article {
  grid-column: content;
  grid-row: 1/-1;
  
}

input:checked ~ main > section > nav > a[rel="prev"] {
  grid-column: 1/2;
}
input:checked ~ main > section > nav > a[rel="next"] {
  grid-column: -2/-1;
}

input:checked ~ main > section > nav > a[rel] {
    background: linear-gradient(var(--story-button-gradient-direction), rgba(0, 0, 0, var(--story-button-gradient-alpha, 0)), transparent);
}

input:checked ~ main > section > nav > a[rel]:hover{
  --story-button-gradient-alpha: 0.4;
}
input:checked ~ main > section > nav > a[rel="prev"] {
  --story-button-gradient-direction: to right;
}

input:checked ~ main > section > nav > a[rel="next"] {
  --story-button-gradient-direction: to left;
}

/* Counter */
main{
  counter-reset: items;
  position: relative;
}

main > section::before{
  counter-increment: items;
  content: counter(items);
  font-family: var(--font-mono);
}

main > section:last-child::after{
  content:"/" ''counter(items);
  font-family: var(--font-mono);
  position: absolute;
  left: 1ch;
  bottom: 0;
}

/*
Cool stuff
- You use the increment per item to get an index
- To get the total you can retrive the counter after all items (outside their parrent for exemple)
*/
              
            
!

JS

              
                
              
            
!
999px

Console