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

              
                <p class="semicircle">Label</p>

<hr>
<h2>How This Works</h2>
<ol>
  <li>
    Uses <code>border-radius: 50%</code> alongside a fixed width and <code>aspect-ratio: 1 / 1</code> to create a circular element.
  </li>
  <li>
    Sets a <code>transparent</code> border on the entire element.
  </li>
  <li>
    Adds two, stacked gradients as a <code>background-image</code>, one which is the desired background colour, and the other which is 50% transparent and 50% the border colour, creating a two-tone, solid block of colour that covers half od the element.
  </li>
  <li>
    Sets <code>background-origin: border-box</code> to ensure that the background image fully overlaps the border.
  </li>
  <li>
    Finally, uses <code>background-clip</code> to set the first gradient (our background colour) to only show within the padding area of the element, whilst allowing the second gradient to continue appearing beneath the border. The first gradient therefore "covers" the second within the element, and is only visible underneath the border, which is transparent and therefore allows it to be seen.
  </li>
  <li>
    Oh, and we use some Custom Properties to make this all easier to control and set the <em>direction</em> the second gradient should  take, allowing us to set the semicircle border on any side: <code>top | bottom | left | right</code>
  </li>
</ol>
              
            
!

CSS

              
                .semicircle-border {
  --thickness: .5em;
  --border-color: orange;
  --background-color: slategray;
  --semicircle-side: left;
  
  /*  Border  */
  border: var(--thickness) solid transparent;
  background-image: linear-gradient(var(--background-color), var(--background-color)), linear-gradient(to var(--semicircle-side), transparent 0% 50%, var(--border-color) 50% 100%);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  border-radius: 50%;

  /*  General styling  */
  display: flex;
  place-items: center;
  width: max-content;
  aspect-ratio: 1 / 1;
  color: white;
  padding: 1rem;
}

/* Styling Everything Else */

body {
  font-family: sans-serif;
}

hr {
  margin-block-start: 3rem;
}

li + li {
  margin-block-start: 1rem;
}

              
            
!

JS

              
                
              
            
!
999px

Console