2018-09-30 22:01:58 +00: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 16:17:33 +00:00
forumTopicId: 301077
2021-01-13 02:31:00 +00:00
dashedName: use-the-css-transform-scale-property-to-scale-an-element-on-hover
2018-09-30 22:01:58 +00:00
---
2020-11-27 18:02:05 +00:00
# --description--
The `transform` property has a variety of functions that let you scale, move, rotate, skew, etc., your elements. When used with pseudo-classes such as `:hover` that specify a certain state of an element, the `transform` property can easily add interactivity to your elements.
2018-09-30 22:01:58 +00: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 08:11:58 +00:00
```css
p:hover {
transform: scale(2.1);
}
```
2020-11-27 18:02:05 +00:00
**Note:** Applying a transform to a `div` element will also affect any child elements contained in the div.
2019-04-28 18:13:38 +00:00
2020-11-27 18:02:05 +00:00
# --instructions--
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
Add a CSS rule for the `hover` state of the `div` and use the `transform` property to scale the `div` element to 1.1 times its original size when a user hovers over it.
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
# --hints--
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
The size of the `div` element should scale 1.1 times when the user hovers over it.
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
```js
assert(code.match(/div:hover\s*?{\s*?transform:\s*?scale\(1\.1\);/gi));
2018-09-30 22:01:58 +00:00
```
2020-11-27 18:02:05 +00:00
# --seed--
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
## --seed-contents--
2018-09-30 22:01:58 +00:00
```html
< style >
2018-10-08 00:01:53 +00:00
div {
2018-09-30 22:01:58 +00:00
width: 70%;
height: 100px;
margin: 50px auto;
background: linear-gradient(
53deg,
#ccfffc ,
#ffcccf
);
}
2018-10-08 00:01:53 +00:00
2018-09-30 22:01:58 +00:00
< / style >
< div > < / div >
```
2020-11-27 18:02:05 +00:00
# --solutions--
2018-09-30 22:01:58 +00:00
2019-04-28 18:13:38 +00: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 22:01:58 +00:00
```