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

              
                <html>

<body>
  <div class='slanted'>
    <p>I was updating my portfolio and wanted to use the forward <span class='no-break'>slash ( / )</span> as a graphic element in the site's main layout. It seemed like it would be easy at first glance, but as I began digging into it actually presented a few very interesting challenges.</p>
    <p>I started by looking around for examples of non-rectangular containers that allowed text to flow naturally inside of them. I assumed it'd be possible with CSS since programs like Adobe Illustrator and Microsoft Word have been doing it for years. I found the CSS Shapes Module and that works very well for simple text content. It can even full justify the text. However it doesn’t allow content to scroll within the container so as the user scrolls down, the entire slanted container appears to move left, which wasn’t the effect I wanted. Instead I took a simpler approach and simply added a transform: skew to the container:</p>
    <img class="normal" src="https://i.imgur.com/HLw6SuM.png" />
    <p class="normal">That was a good start, scrolling worked as expected and resizing was handled with only CSS, but the obvious problem is that now the text and images are slanted as well. I made a few attempts to solve this with CSS but eventually came up with an even simpler solution: create a new font with the reverse slant using FontForge, an open-source font editor.</p>
    <p>I'd chosen Roboto Condensed Light for the site's main content so I opened the .ttf file in FontForge, selected all the glyphs, and applied a skew of 14 degrees to compensate for the container’s slant, and saved it out as Roboto-Rev-Italic.ttf.
    </p>
    <p>That worked great for text, even selecting functioned normally. For images and video, which are display:block elements I was able to simply apply the reverse slant to their transform property. Pseudoelements background give them to span the entire width of the container as well.
    </p>
    <img src="https://i.imgur.com/HLw6SuM.png" />
    <p>See it in action at <a href="https://daveseidman.com" target="_blank">daveseidman.com</a> and use the comments section to suggest other methods, I’m curious to see other way of achieving the same effect. </p>
  </div>
</body>
</html>
              
            
!

CSS

              
                @import url('https://assets.codepen.io/9632/roboto-rev-italic.ttf');

@import url('https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@300&display=swap');

@font-face {
  font-family: 'Roboto Condensed Light';
  src: url('https://assets.codepen.io/9632/roboto-rev-italic.ttf') format('truetype');
}

$skew-amount: -14deg;

body, html {
  font-size: 14px;
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Roboto Condensed Light';
  font-variant-ligatures: none;
  background: gray;
  line-height: 1.5rem;
}

.no-break {
  white-space: nowrap;
}

.slanted {
  background: white;
  width: 50%;
  position: absolute;
  left: 50%;
  transform: translateX(-50%) skew($skew-amount);
  text-align: justify;
  overflow-x: hidden;
  overflow-y: auto;
  height: calc(100% - 2rem);
  padding: 1rem;
  font-family: 'Roboto Condensed Light';
  
  .normal {
    transform: none;
    font-family: 'Roboto Condensed', sans-serif;
  }
  
  img {
    width: 100%;
    transform: skew(-$skew-amount);
    position: relative;
     
    &:after {
      display: block;
      content: '1';
      background: red;
      position: absolute;
      top: 0;
      left: 0;
      width: 200%;
      height: 100%;
    }
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console