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.
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.
練習題:
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.
練習代碼:
<style> div { width: 70%; height: 100px; margin: 50px auto; background: linear-gradient( 53deg, #ccfffc, #ffcccf ); } div:hover { transform: scale(1.1); } </style> <div></div>
練習效果:
滑鼠移動過去,放大1.1倍,挺好玩的
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/116167.html
標籤:Html/Css
上一篇:FCC---Use the CSS Transform scale Property to Change the Size of an Element
下一篇:FCC---Use the CSS Transform Property skewX to Skew an Element Along the X-Axis
