2018-09-30 23:01:58 +01:00
---
id: 587d78a5367417b2b2512ada
title: Use the CSS Transform scale Property to Scale an Element on Hover
challengeType: 0
videoUrl: 'https://scrimba.com/c/cyLPJuM'
2019-08-05 09:17:33 -07:00
forumTopicId: 301077
2018-09-30 23:01:58 +01:00
---
## Description
< section id = 'description' >
2019-04-03 03:43:27 +02:00
The < code > transform< / code > property has a variety of functions that let you scale, move, rotate, skew, etc., your elements. When used with pseudo-classes such as < code > :hover< / code > that specify a certain state of an element, the < code > transform< / code > property can easily add interactivity to your elements.
2018-09-30 23:01:58 +01:00
Here's an example to scale the paragraph elements to 2.1 times their original size when a user hovers over them:
2019-05-14 01:11:58 -07:00
```css
p:hover {
transform: scale(2.1);
}
```
2019-04-29 01:13:38 +07:00
2019-03-22 22:02:12 +08:00
< strong > Note:< / strong > Applying a transform to a < code > div< / code > element will also affect any child elements contained in the div.
2018-09-30 23:01:58 +01:00
< / section >
## Instructions
< section id = 'instructions' >
Add a CSS rule for the < code > hover< / code > state of the < code > div< / code > and use the < code > transform< / code > property to scale the < code > div< / code > element to 1.1 times its original size when a user hovers over it.
< / section >
## Tests
< section id = 'tests' >
```yml
2018-10-04 14:37:37 +01:00
tests:
- text: The size of the < code > div</ code > element should scale 1.1 times when the user hovers over it.
2019-07-24 02:42:26 -07:00
testString: assert(code.match(/div:hover\s*?{\s*?transform:\s*?scale\(1\.1\);/gi));
2018-09-30 23:01:58 +01:00
```
< / section >
## Challenge Seed
< section id = 'challengeSeed' >
< div id = 'html-seed' >
```html
< style >
2018-10-08 01:01:53 +01:00
div {
2018-09-30 23:01:58 +01:00
width: 70%;
height: 100px;
margin: 50px auto;
background: linear-gradient(
53deg,
#ccfffc ,
#ffcccf
);
}
2018-10-08 01:01:53 +01:00
2018-09-30 23:01:58 +01:00
< / style >
< div > < / div >
```
< / div >
< / section >
## Solution
< section id = 'solution' >
2019-04-29 01:13:38 +07:00
```html
< style >
div {
width: 70%;
height: 100px;
margin: 50px auto;
background: linear-gradient(
53deg,
#ccfffc ,
#ffcccf
);
}
div:hover {
transform: scale(1.1);
}
< / style >
< div > < / div >
2018-09-30 23:01:58 +01:00
```
< / section >