Examples would be rotating, moving, skewing, and scaling elements. Modern day web is full of animations. To achieve the same effect while scaling up rather than down, see the following example code: To prevent this, a transition can be added so you can control the change, making it look smoother. CSS Image hover zoom effects Image hover Zoom n’ Rotate effect with Pure CSS. There are a few types of commonly used transforms. We're going to create some fundamental CSS3 … A simple animation for example, could be zooming-in images on hover event — within a specific viewport container. In older browsers you will see either no effects, or the transforms taking place without any animation. scale() makes an element larger or smaller and can be set to specifically affect the width (X-axis) or height (Y-axis). Now for the scale transform. How to use CSS3 transforms. The rotate() CSS function defines a transformation that rotates an element around a fixed point on the 2D plane, without deforming it. Expanding or Contracting Size with a CSS transform. CSS: Animation Using CSS Transforms Tweet 7 Shares 0 Tweets 40 Comments. transform-origin will make a big difference here too. Resize images with the CSS width and height properties¶. The examples on this page will work now in Firefox, Safari, Chrome, Opera and Internet Explorer 10. Without a transition, an element being transformed would change abruptly from one state to another. To combine different values for X an Y, separate them with a comma. Set the width property to a percentage value and the height to "auto". This tutorial will take you back to the very basics. .element { transform: scale(2, .5); } Or you can be more specific without using the shorthand function: transform: scaleX(2); transform: scaleY(.5); But scale() is just one of many transform functions that are available: Values. The image is going to be responsive (it will scale up and down). For example, transform: scale(1, 2); Rotate Now let’s look at the transform value scale(). My favorite techniques involving pseudo-elements and transform Use transform first for CSS transitions and animations. The problem here was I wrongly set transform-origin: 0 0; only on :hover but not for the inital state; Thanks to Sven Wolfermann for the hint.. Don’t scale the children # Just like with translate(), scale() adjusts the size of the object relative to its own width or height. 1 is regular size, 2 will double it in size, 0.5 will make it half the size. You can use the CSS transform property to increase or decrease the image size on mouse hover without affecting the surrounding elements or content.. Let's try out the following example to understand how it basically works: For example, transform: scaleX(2). The percentage values reflect the scale parameters, in this case moving the element up and back by the correct amount to keep the top left corner in the same place. Its result is a data type.. How to transform image size on mouse hover without affecting the layout in CSS. Another way of resizing images is using the CSS width and height properties. Animating the transform property is a million times faster than animating width, height, or any of the other properties that impact layout and will trigger a reflow. .square {width: 200px; height: 200px; border-radius: 40px;}.square-resized {width: 100px;}.square-transformed {transform: scaleX (0.5);}. Scale will increase or decrease the size of the element. This morning I asked on twitter for help with using transform: scale(); The first problem was that I wanted to animate the box the same way with scale(); as with changing the width/height of the element. To set a scale for just one axis, you can define X or Y on the property. scale(): Affects the size of the element. There are some amazing examples of CSS transforms and transitions, and whilst you may be blown away by them, there's a good chance that you're also overwhelmed and a bit intimidated! Topic: HTML / CSS Prev|Next Answer: Use the CSS transform property. If we apply a scale transform to an element, we change its size. But if we animate it, the result will be that weirdly stretched shape.