Transforms
Follow this guide to learn how to add a transform to a website using the transform
CSS property!
Setup
Follow these steps to set up a new project for transforms.
- Click here to go to the Starter project
- Open the index.html file for editing
- Add a
class
attribute to the second<p>
element that says "Style this paragraph..." - Set the
class
to beupdate
- Find the
<style></style>
element - Create a new ruleset to style the paragraph by its class
- Use
.update
as the selector - After the selector, add curly brackets (
{
and}
)
- Use
At this point, the added code should look something like this:
HTML
<p class="update">Style this paragraph...</p>
CSS
.update {
}
The project should be ready for styling.
Adding a Transform
The cool thing about the transform
property is that there are a ton of different possibilities. You can do things like rotate, scale, move, and skew! This guide will only show one of the functions - the skewY
function.
- Open the index.html file for editing, and find the
<style></style>
element - In the
.update
ruleset (between{
and}
), create a new property declaration withtransform
- Set the value for the
transform
property to beskewY(-20deg)
Load up the page, and see the text skew The code in the <style></style>
element should look something like this:
.update {
transform: skewY(-20deg);
}
Try playing around with the different values to see where it leads. Some different functions to try include rotate
, scale
, translate
, and perspective
.
Click here for an interactive transform
generator tool! This site will allow you play around with the different possibilities, and will give you code to copy and paste at the end.