Software, your way.
burger menu icon
WillMaster

WillMaster > LibraryMarketing With Software

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

Tilted Content

Sometimes tilting an image or some text has exactly the effect on your page design that you're looking for. You do it with the transform property.

There is another reason to tilt something. It gets attention.

When a person wants to get attention without annoying the site visitor with animations, it generally is done with something unexpected or unusual. A tilted image or text can provide that.

The CSS3 transform property can do lots of things. This article focuses exclusively on its rotate value.

The rotate value is used to tilt an image or text a specific amount. Here is an example, text rotated toward the left 1½ degrees.

Text tilted with a rotation of 1.5 degrees.

The eye is attracted to anomalies. It generally doesn't take very much to get attention. Just 1½ degrees did the trick in this case.

Here is the code for the above tilted text.

<p style="transform:rotate(-1.5deg); text-align:center;">
Text tilted with a rotation of 1.5 degrees.
</p>

We'll do three more examples.

  1. An image in a div with the div tilted toward the right.
  2. The same div, the image tilted toward the right within the div itself.
  3. The same div, the image tilted toward the left so it appears only the div is tilted, not the image.
52 Good-to-Know Techbits book cover

The div with the image on the right is tilted toward the right with a 5 degree rotation. The image is linked to the sales page.

When a div is tilted, everything within the div is also tilted, unless coded otherwise.

Here is the source code for review.

<div style="transform:rotate(5deg); width:80px; float:right; border:1px solid black; padding:20px 20px 10px 20px; border-radius:9px;">
<a href="https://willbontrager.com/books-Will-Bontrager.php">
<img 
  src="https://willbontrager.com/52/images/cover-300px.jpg"
  style="max-width:100%; height:auto; border:none; outline:none;" 
  alt="52 Good-to-Know Techbits book cover">
</a>
</div>
52 Good-to-Know Techbits book cover

Now, the image within the div is also tilted toward the right. Again with a 5 degree rotation.

And here is the source code for review.

<div style="transform:rotate(5deg); width:80px; float:right; border:1px solid black; padding:20px 20px 10px 20px; border-radius:9px;">
<a href="https://willbontrager.com/books-Will-Bontrager.php">
<img 
  src="https://willbontrager.com/52/images/cover-300px.jpg"
  style="transform:rotate(5deg); max-width:100%; height:auto; border:none; outline:none;" 
  alt="52 Good-to-Know Techbits book cover">
</a>
</div>
52 Good-to-Know Techbits book cover

For the final example, the image within the div is tilted left so it appears to be upright within the tilted div.

Here is the source code for the final example.

<div style="transform:rotate(5deg); width:80px; float:right; border:1px solid black; padding:20px 20px 10px 20px; border-radius:9px;">
<a href="https://willbontrager.com/books-Will-Bontrager.php">
<img 
  src="https://willbontrager.com/52/images/cover-300px.jpg"
  style="transform:rotate(-5deg); max-width:100%; height:auto; border:none; outline:none;" 
  alt="52 Good-to-Know Techbits book cover">
</a>
</div>

In essence, you specify the transform:rotate(#deg); as a CSS rule for the element you want tilted. Replace # with the number of degrees to rotate. A negative number specifies a leftward tilt and a positive number specifies a rightward tilt.

The transform:rotate(#deg); rule (# replaced with a number) can be applied to block elements — p, div, pre and so forth. And also to some inline elements, such as the img element.

Use it in page design when appropriate. And to focus attention.

(This article first appeared with an issue of the Possibilities newsletter.)

Will Bontrager

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC