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

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

              
                <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="symbols">
  
    <symbol id="symbol-test-1" viewBox="0 0 325 90" preserveAspectRatio="none">
      <polygon points="325 45
                       288 90
                       0 90
                       0 0
                       288 0"/>
    </symbol>
  
  <!--

  1. Beginning with base polygon shape, add an even stroke width with rounded joins.
  2. Divide even stroke number by 2. So a stroke of 20 / 2 = 10
  3. Add halved stroke number to both X and Y of viewBox coordinates.
  4. Change all instances of 0 to halved stroke number.
  5. Quarter stroke number and add this value to Y coordinate of middle point.

  It's actually not necessary to use an even stroke, because we can use decimals.
  It just makes the math easier and more intuitive.

  To test that coordinates were properly shifted, set item margin-bottom to 1px.
  They should be flush with 1px gap.

  -->
  
  <symbol id="symbol-test-2" viewBox="0 0 335 100" preserveAspectRatio="none">
    <polygon points="325 50
                     288 90
                     10 90
                     10 10
                     288 10" 
             stroke-linejoin="round"
             stroke-width="20"/>
  </symbol>
  
  <symbol id="symbol-test-3" viewBox="0 0 333 98" preserveAspectRatio="none">
    <polygon points="325 49
                     288 90
                     8 90
                     8 8
                     288 8" 
             stroke-linejoin="round"
             stroke-width="16"/>
    </symbol>
  
    <symbol id="symbol-test-4" viewBox="0 0 332 97" preserveAspectRatio="none">
      <polygon points="325 48.5
                       288 90
                       7 90
                       7 7
                       288 7"
               stroke-linejoin="round"
               stroke-width="14"/>
    </symbol>
  
    <symbol id="symbol-test-5" viewBox="0 0 332 97" preserveAspectRatio="none">
        <polygon points="325 48.5 
                         288 90 
                         7 90 
                         7 7 
                         288 7"
                 fill="black" 
                 stroke="black" 
                 stroke-linejoin="round" 
                 stroke-width="14"/>
      </symbol>
  
</svg>

<div id="test-1" class="item">
  Mr. and Mrs. Dursley, of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much.
  <svg>
    <use xlink:href="#symbol-test-4"></use>
  </svg>
</div>

<div id="test-2" class="item">
  They were the last people you'd expect to be involved in anything strange or mysterious, because they just didn't hold with such nonsense.
  <svg>
    <use xlink:href="#symbol-test-4"></use>
  </svg>
</div>

<div id="test-3" class="item">
  Chapter 1
  <svg>
    <use xlink:href="#symbol-test-4"></use>
  </svg>
</div>

<div id="test-4" class="item item-2">
  They were the last people you'd expect to be involved in anything strange or mysterious, because they just didn't hold with such nonsense.
</div>
              
            
!

CSS

              
                @color: #FFF;

.item
{
  // transition: all 300ms linear;
  
  display: flex;
  box-sizing: border-box;
  color: hsv(0, 0, 30%);
  flex-flow: column wrap;
  justify-content: center;
  margin-bottom: 10px;
  min-height: 90px;
  padding: 20px 45px 20px 20px;
  position: relative;
    top: 0;
    left: 0;
  width: 325px;
  
  &:hover
  {
    // There does appear to be some "stickiness"
    // on this transform, especially if hovering
    // quickly between the items. Doesn't happen
    // if transition only exists on hover.
    // Possibly due to referencing same symbol?
    transform: translateX(20px);
    transition: all 300ms linear;
  }
  
  svg
  {
    display: block;
    fill: @color;
    height: 100%;
    opacity: 0.75;
    position: absolute;
      top: 0;
      right: 0;
      z-index: -1;
    stroke: @color;
    width: 100%;
  }
}

// Why doesn't this work in Firefox? :(
// Sensitive to how SVG mark-up is crafted? That does seem to be where I'm having problems.
// Otherwise if it can work between browsers, this is a great solution.
// Major pro: can use CSS properties instead of SVG filters, which are far less
// intuitive to work with and change.
.item-2
{
  background-color: rgba(255, 255, 255, 0.50);
  box-shadow: inset 1px 1px 4px rgba(0, 0, 0, 0.10);
  mask: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgMzMyIDk3IiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJub25lIj48cG9seWdvbiBwb2ludHM9IjMyNSA0OC41IDI4OCA5MCA3IDkwIDcgNyAyODggNyIgZmlsbD0iYmxhY2siIHN0cm9rZT0iYmxhY2siIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0cm9rZS13aWR0aD0iMTQiLz4KPC9zdmc+') no-repeat 50% 50%;
}

body
{
  background: hsv(0, 0, 93%);
  margin: 1.000em;
}

#symbols
{
  display: none;
}
              
            
!

JS

              
                
              
            
!
999px

Console