Software, your way.
How To Get Good Custom Software
(Download)
(PDF)
burger menu icon
WillMaster

WillMaster > LibraryWeb Page and Site Features

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!

Rotate To Attract

Doing a slight rotation on text or an image can attract the eye. You'll find several examples here, along with the code to duplicate them.

Elements that are boxes in CSS can be rotated. An image with an img tag can be rotated. The contents of a div element can be rotated. But the contents of a span element can not be rotated with the transform:rotate() property.

To rotate something, use transform:rotate(-15deg), where -15deg is the amount of degrees to rotate (minus 15 degrees, in this case). Replace -15deg with the amount and direction of rotation you want.

Here is an example image rotated slightly toward the right, using transform:rotate(1.2deg) for the rotation.

The code for the above is this:

<img style="transform:rotate(1.2deg);" src="https://www.willmaster.com/possibilities/images/poss1253_landscape.png">

This next example is a div. The div contains both text and an image. The containing div's CSS contains transform:rotate(-11.0deg) for the rotation.

Happy Birthday, Precious!

Here is the code for the div with text and image:

<div style="transform:rotate(-11.0deg); text-align:center;">
   <div style="font-size:14pt; font-weight:bold;">Happy Birthday, Precious!</div>
   <img src="https://www.willmaster.com/possibilities/images/poss1253_birthdaycake.png">
</div>

Let's do one more example. For this, let's rotate words within a string of words. Here is the example:

A person can go
up
or go
down
or stay still.

The rotated words "up" and "down" in the above example are within div tags with style display:inline-block; (because span contents can not be rotated). Here is the source code:

A person can 
go <div style="display:inline-block; transform:rotate(-11.0deg);">up</div> or 
go <div style="display:inline-block; transform:rotate(11.0deg);">down</div> or 
stay still.

The CSS transform:rotate() property can be used for getting attention to specific elements of your content. The examples and their source code show how.

(This content first appeared in 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
software index page

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