* ADD: transform affects DIV child contents After spending some time figuring out how to prevent text in a div being skewed as well as the div, I think it is worth mentioning that applying a transform to a div element will also affect elements contained inside of it. Perhaps the transform challenge pages could include how to negate the effects of the transform on child elements of divs. * Fix: moved my commit to Description Moved my commit text into the Description section as suggested. * Fix: Changed </div> to </code> Changed the closing </div> tag to </code> as suggested. * Fix: Changed markdown ** to <strong> As advised on a previous pull request, I have removed the markdown ** ** and replaced it with HTML <strong></strong>.
1.8 KiB
1.8 KiB
id, title, challengeType, videoUrl
id | title | challengeType | videoUrl |
---|---|---|---|
587d78a5367417b2b2512ada | Use the CSS Transform scale Property to Scale an Element on Hover | 0 | https://scrimba.com/c/cyLPJuM |
Description
transform
property has a variety of functions that lets 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.
Here's an example to scale the paragraph elements to 2.1 times their original size when a user hovers over them:
p:hover {
transform: scale(2.1);
}
NOTE: Applying a transform to a div
element will also affect any child elements contained in the div.
Instructions
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.
Tests
tests:
- text: The size of the <code>div</code> element should scale 1.1 times when the user hovers over it.
testString: assert(code.match(/div:hover\s*?{\s*?transform:\s*?scale\(1\.1\);/gi), 'The size of the <code>div</code> element should scale 1.1 times when the user hovers over it.');
Challenge Seed
<style>
div {
width: 70%;
height: 100px;
margin: 50px auto;
background: linear-gradient(
53deg,
#ccfffc,
#ffcccf
);
}
</style>
<div></div>
Solution
var code = "div:hover {transform: scale(1.1);}"