In 2018, the web design industry is going to start looking very different. Literally.
With all the tools we’re gaining in CSS, designers are going to have new ability to experiment. I wrote about some of those tools on CSS Tricks: Five Design Fears to Vanquish with CSS Grid.
I’m still convinced that taking inspiration from punk rock design of the 70s and 80s is going to be a trend.
If you want to start small, introduce some angles to your design. This is a simple trick to angle a stripe of content without adding awkward white space.
Free ebook - Common CSS Grid Patterns
CSS Grid is a revolution in web layout. With this ebook, I cover 3 design patterns that Grid solves easier, better and more creatively to help push our designs in better directions.Download Now!
Start with a regular stripe
We all know this design pattern: full width background and nice promotional content.
We set up very simple markup:
Add a pinch of very simple CSS and we’re done.
This is a lovely serviceable stripe of content. You also get to dig on a nice linear-gradient while you’re there.
Use transform: rotate() to introduce the angle
The transform CSS property has a load of great functions. One of the easiest functions to use is rotate(). It takes an angle unit such as 45deg and rotates the element by that amount. A positive integer is a clockwise turn and negative is a counter-clockwise turn.
You’ll notice from the photo that this introduces an issue. This is still a rectangle and by rotating the rectangle, we see the corners.
This doesn’t feel professional, so we need this to stay flush to the browser edge.
skew() to the rescue
By taking the same angle we used in our rotate() function, we can skew the element back. This angles the left and right sides of our element back to their starting points.
The transform property can take multiple functions, so we apply it on the same line of CSS.
The discerning designer eye will notice one more issue with our implementation. The text is now skewed. This may be something you want. The skewed text bothers me slightly, so let’s unskew it.
Time to unskew the text
I’m not a huge fan of introducing new markup for styling if I can avoid it, but with the introduction of a content container, we can fix our text skew.
Chances are decent, you had a container here anyway to set a width on your content.
By applying a skew of the negative angle we’ve been using, the text will re-skew back to its initial angle. You can also use this method to un-rotate the text, as well, if that’s your need.
This gives us clean lines with a hint of punk rock. See this in action on CodePen.
If you’re still doing things the same way you’ve always done them, it’s time to spice things up. Adding angles is an easy and painless way of tossing some cayenne into your design process.