CSS scaleY()
The scaleY() function is a CSS transform function that resizes an element along the y-axis. It modifies the height of an element by scaling its vertical dimension.
Syntax
transform: scaleY(y);
Parameters:
y: A number or percentage representing the scaling factor to apply along the y-axis. A value of1leaves the element unchanged, values greater than1increase the height, and values between0and1decrease the height. Negative values create a vertical reflection.
Return value:
The scaleY() function returns a <transform-function> data type that can be used with the transform property.
Example 1: Scaling a Box Vertically
In this example, the height of a box is scaled along the y-axis to create a stretched effect. The HTML code is:
<!DOCTYPE html><html><head><link rel="stylesheet" href="style.css" /><title>ScaleY Box Example</title></head><body><div class="container"><div class="box small">Small</div><div class="box tall">Tall</div></div></body></html>
The CSS code is:
body {display: flex;justify-content: center;align-items: center;height: 100vh;background-color: #f8f8f8;}.container {display: flex;gap: 40px;}.box {width: 120px;height: 120px;background-color: #3498db;color: white;display: flex;justify-content: center;align-items: center;font-size: 16px;font-weight: bold;}.small {transform: scaleY(0.8);background-color: #2ecc71;}.tall {transform: scaleY(1.8);background-color: #e67e22;}
This example results in the following output:

Example 2: Animated Button Grow on Hover
In this example, a button grows taller along the y-axis when hovered over. The HTML code is:
<!DOCTYPE html><html><head><link rel="stylesheet" href="style.css" /><title>ScaleY Button Animation</title></head><body><button class="btn">Hover Me</button></body></html>
The CSS code is:
body {display: flex;justify-content: center;align-items: center;height: 100vh;background-color: #ecf0f1;}.btn {width: 150px;height: 50px;font-size: 18px;font-weight: bold;background-color: #3498db;color: white;border: none;border-radius: 8px;transition: transform 0.4s ease;}.btn:hover {transform: scaleY(1.5);}
This example results in the following output:

Example 3: Image Column Stack with Vertical Scaling
In this example, images are stacked and scaled vertically to create a layered effect. The HTML code is:
<!DOCTYPE html><html><head><link rel="stylesheet" href="style.css" /><title>Vertical Image Stack</title></head><body><div class="image-stack"><div class="image-box box1">1</div><div class="image-box box2">2</div><div class="image-box box3">3</div></div></body></html>
The CSS code is:
body {display: flex;justify-content: center;align-items: flex-end;height: 100vh;background: linear-gradient(120deg, #6a11cb, #2575fc);}.image-stack {display: flex;gap: 20px;align-items: flex-end;}.image-box {width: 80px;height: 80px;background-color: #ff6b6b;display: flex;justify-content: center;align-items: center;color: white;font-size: 18px;font-weight: bold;border-radius: 6px;transition: transform 0.3s ease;}.box1 {transform: scaleY(1.1);background-color: #ff6b6b;}.box2 {transform: scaleY(1.5);background-color: #4ecdc4;}.box3 {transform: scaleY(2);background-color: #ffd93d;}.image-box:hover {transform: scaleY(2.3);}
This example results in the following output:

Frequently Asked Questions
1. What is the transform scale in CSS?
Transform scale resizes elements along different axes. scaleY() specifically scales the element vertically.
2. What does transform translateY(-50%) mean?
It moves an element up by 50% of its own height relative to its current position.
3. What is scaleY?
ScaleY is a CSS transform that stretches or compresses an element along the vertical axis.
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn CSS on Codecademy
- Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
- Includes 34 Courses
- With Professional Certification
- Beginner Friendly.115 hours
- In this CSS tutorial, you’ll learn how to add CSS to visually transform HTML into eye-catching sites.
- Beginner Friendly.6 hours