Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <h1>Playing with CSS Logical Properties Support</h1>

<p>
  Used in the blog post <cite><a href="https://adrianroselli.com/2019/11/css-logical-properties.html">CSS Logical Properties</a></cite>.
</p>

<p>
  The default state is in bold because it is easier to spot once the layout has gone out of order from what you expect.
</p>

<fieldset>
  <legend>Change the <code>body</code> to…</legend>
  <label>
    <input type="radio" name="bodyStyle" value="" onclick="styleBody(this.value);" checked>
    <strong>Use default <code>writing-mode</code> and <code>direction</code>.</strong>
  </label>
  <label>
    <input type="radio" name="bodyStyle" value="writing-mode: vertical-lr;" onclick="styleBody(this.value);">
    Set <code>writing-mode: vertical-lr</code>.
  </label>
  <label>
    <input type="radio" name="bodyStyle" value="direction: rtl;" onclick="styleBody(this.value);">
    Set <code>direction: rtl</code>.
  </label>
  <label>
    <input type="radio" name="bodyStyle" value="writing-mode: vertical-rl;" onclick="styleBody(this.value);">
    Set <code>writing-mode: vertical-rl</code>.
  </label>
</fieldset>

<p>
  I am using <code>&lt;button&gt;</code> as my examples because they already have borders, inline-block layout, and get focus natively in case you (like me) tab through a page and sometimes set focus to a thing to keep track where you are.
</p>

<h2>Sizing and Text Alignment</h2>

<p>
  These styles are carried forward for all the buttons after these first two, unless you see them explicitly overridden.
</p>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>min-width: 5em;<br>
      min-height: 2em;<br>
      text-align: left;<br>
      padding: .5em 1em;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>min-inline-size: 5em;<br>
      min-block-size: 2em;<br>
      text-align: start;<br>
      padding-block: .5em;<br>
      padding-inline: 1em;</code>
  </button>
</div>

<h2>Borders</h2>

<p>
  Headings reflect the original property names, which should be easier for referencing the new property names.
</p>

<h3 class="BorderTop">Border Top</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>border-top: .3em double #00f;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>border-block-start: .3em double #00f;</code>
  </button>
</div>

<h3 class="BorderRight">Border Right</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>border-right: .5em dotted #0c0;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>border-inline-end: .5em dotted #0c0;</code>
  </button>
</div>

<h3 class="BorderBottom">Border Bottom</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>border-bottom: .2em solid #c00;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>border-block-end: .2em solid #c00;</code>
  </button>
</div>

<h3 class="BorderLeft">Border Left</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>border-left: .3em dashed #333;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>border-inline-start: .3em dashed #333;</code>
  </button>
</div>

<h3 class="BorderTop BorderRight BorderBottom BorderLeft">All the Borders</h3>

<div>
  <button type="button" class="typical">
    Traditional
  </button>

  <button type="button" class="logical">
    Logical
  </button>
</div>

<h3 class="BorderBlock">Border Block</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>border-top: .3em solid #000;<br>
    border-bottom: .3em solid #000;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>border-block: .3em solid #000;</code>
  </button>
</div>

<h3 class="BorderInline">Border Inline</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>border-left: .3em solid #000;<br>
    border-right: .3em solid #000;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>border-inline: .3em solid #000;</code>
  </button>
</div>



<h2 class="Radii">Border Radius</h2>

<p>
  Headings reflect the original property names, which should be easier for referencing the new property names.
</p>

<h3 class="BorderTopLeftRadius">Border Top Left Radius</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>border-top-left-radius: .75em;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>border-start-start-radius: .75em;</code>
  </button>
</div>

<h3 class="BorderTopRightRadius">Border Top Right Radius</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>border-top-right-radius: 1.5em;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>border-start-end-radius: 1.5em;</code>
  </button>
</div>

<h3 class="BorderBottomRightRadius">Border Bottom Right Radius</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>border-bottom-right-radius: .75em;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>border-end-end-radius: .75em;</code>
  </button>
</div>

<h3 class="BorderBottomLeftRadius">Border Bottom Left Radius</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>border-bottom-left-radius: 1.5em;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>border-end-start-radius: 1.5em;</code>
  </button>
</div>

<h3 class="BorderTopLeftRadius BorderTopRightRadius BorderBottomRightRadius BorderBottomLeftRadius">All the Border Radii</h3>

<div>
  <button type="button" class="typical">
    Traditional
  </button>

  <button type="button" class="logical">
    Logical
  </button>
</div>


<h2>Padding</h2>

<p>
  Headings reflect the original property names, which should be easier for referencing the new property names.
</p>

<h3 class="PaddingTop">Padding Top</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>padding-top: 2em;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>padding-block-start: 2em;</code>
  </button>
</div>

<h3 class="PaddingRight">Padding Right</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>padding-right: 2em;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>padding-inline-end: 2em;</code>
  </button>
</div>

<h3 class="PaddingBottom">Padding Bottom</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>padding-bottom: 2em;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>padding-block-end: 2em;</code>
  </button>
</div>

<h3 class="PaddingLeft">Padding Left</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>padding-left: 2em;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>padding-inline-start: 2em;</code>
  </button>
</div>

<h3 class="PaddingBlock">Padding Block</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>padding: 2em 0;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>padding-block: 2em;</code>
  </button>
</div>

<h3 class="PaddingInline">Padding Inline</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>padding: 0 2em;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>padding-inline: 2em;</code>
  </button>
</div>




<h2>Margin</h2>

<p>
  Headings reflect the original property names, which should be easier for referencing the new property names.
</p>

<h3 class="MarginTop">Margin Top</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>margin-top: 2em;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>margin-block-start: 2em;</code>
  </button>
</div>

<h3 class="MarginRight">Margin Right</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>margin-right: 2em;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>margin-inline-end: 2em;</code>
  </button>
</div>

<h3 class="MarginBottom">Margin Bottom</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>margin-bottom: 2em;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>margin-block-end: 2em;</code>
  </button>
</div>

<h3 class="MarginLeft">Margin Left</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>margin-left: 2em;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>margin-inline-start: 2em;</code>
  </button>
</div>

<h3 class="MarginBlock">Margin Block</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>margin: 2em 0;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>margin-block: 2em;</code>
  </button>
</div>

<h3 class="MarginInline">Margin Inline</h3>

<div>
  <button type="button" class="typical">
    Traditional:<br>
    <code>margin: 0 2em;</code>
  </button>

  <button type="button" class="logical">
    Logical:<br>
    <code>margin-inline: 2em;</code>
  </button>
</div>


            
          
!
            
              body {
  background-color: #fff;
  color: #333;
  margin: 1em;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto,
    Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  line-height: 1.5;
/*     letter-spacing: 0.12em; */
/*     word-spacing: 0.16em; */
/*     font-size: 200%; */
}

code {
  font-family: "Lucida Console", monospace;
  color: #060;
}

fieldset {
  margin: 1em;
}

label {
  display: block;
  margin: .5em 0;
}

label:focus-within {
  outline: .1em solid #00c;
}

div {
  display: flex;
  justify-content: space-around;
}

button:focus {
  box-shadow: 0 0 .5em rgba(0,0,0,.75);
}

button.typical {
  min-width: 5em;
  min-height: 3em;
  text-align: left;
  padding: .5em 1em;
}

button.logical {
  min-inline-size: 5em;
  min-block-size: 3em;
  text-align: start;
  padding-block: .5em;
  padding-inline: 1em;
}

.BorderTop + div .typical {
  border-top: .3em double #00f;
}

.BorderTop + div .logical {
  border-block-start: .3em double #00f;
}

.BorderRight + div .typical {
  border-right: .5em dotted #0c0;
}

.BorderRight + div .logical {
  border-inline-end: .5em dotted #0c0;
}

.BorderBottom + div .typical {
  border-bottom: .2em solid #c00;
}

.BorderBottom + div .logical {
  border-block-end: .2em solid #c00;
}

.BorderLeft + div .typical {
  border-left: .3em dashed #333;
}

.BorderLeft + div .logical {
  border-inline-start: .3em dashed #333;
}

.BorderBlock + div .typical {
  border-top: .3em solid #000;
  border-bottom: .3em solid #000;
}

.BorderBlock + div .logical {
  border-block: .3em solid #000;
}

.BorderInline + div .typical {
  border-left: .3em solid #000;
  border-right: .3em solid #000;
}

.BorderInline + div .logical {
  border-inline: .3em solid #000;
}

.Radii + p + h3 + div button,
.Radii + p + h3 + div + h3 + div button,
.Radii + p + h3 + div + h3 + div + h3 + div button,
.Radii + p + h3 + div + h3 + div + h3 + div + h3 + div button,
.Radii + p + h3 + div + h3 + div + h3 + div + h3 + div + h3 + div button {
  border: .2em solid #333;
}

.BorderTopLeftRadius + div .typical {
  border-top-left-radius: .75em;
}

.BorderTopLeftRadius + div .logical {
  border-start-start-radius: .75em;
}

.BorderTopRightRadius + div .typical {
  border-top-right-radius: 1.5em;
}

.BorderTopRightRadius + div .logical {
  border-start-end-radius: 1.5em;
}

.BorderBottomRightRadius + div .typical {
  border-bottom-right-radius: .75em;
}

.BorderBottomRightRadius + div .logical {
  border-end-end-radius: .75em;
}

.BorderBottomLeftRadius + div .typical {
  border-bottom-left-radius: 1.5em;
}

.BorderBottomLeftRadius + div .logical {
  border-end-start-radius: 1.5em;
}

.PaddingTop + div .typical {
  padding-top: 2em;
}

.PaddingTop + div .logical {
  padding-block-start: 2em;
}

.PaddingRight + div .typical {
  padding-right: 2em;
}

.PaddingRight + div .logical {
  padding-inline-end: 2em;
}

.PaddingBottom + div .typical {
  padding-bottom: 2em;
}

.PaddingBottom + div .logical {
  padding-block-end: 2em;
}

.PaddingLeft + div .typical {
  padding-left: 2em;
}

.PaddingLeft + div .logical {
  padding-inline-start: 2em;
}

.PaddingBlock + div .typical {
  padding: 2em 0;
}

.PaddingBlock + div .logical {
  padding-block: 2em;
}

.PaddingInline + div .typical {
  padding: 0 2em;
}

.PaddingInline + div .logical {
  padding-inline: 2em;
}

.MarginTop + div .typical {
  margin-top: 2em;
}

.MarginTop + div .logical {
  margin-block-start: 2em;
}

.MarginRight + div .typical {
  margin-right: 2em;
}

.MarginRight + div .logical {
  margin-inline-end: 2em;
}

.MarginBottom + div .typical {
  margin-bottom: 2em;
}

.MarginBottom + div .logical {
  margin-block-end: 2em;
}

.MarginLeft + div .typical {
  margin-left: 2em;
}

.MarginLeft + div .logical {
  margin-inline-start: 2em;
}

.MarginBlock + div .typical {
  margin: 2em 0;
}

.MarginBlock + div .logical {
  margin-block: 2em;
}

.MarginInline + div .typical {
  margin: 0 2em;
}

.MarginInline + div .logical {
  margin-inline: 2em;
}

            
          
!
            
              function styleBody(CSSbits) {
  var theBody = document.getElementsByTagName('body');
  theBody[0].style = CSSbits;
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console