I have a static element
<img src="whatever.jpg" /> when I hover it, I wish to scale it to become fullscreen, absolute positioned. Is this possible to do using just css?
I have a static element
<img src="whatever.jpg" /> when I hover it, I wish to scale it to become fullscreen, absolute positioned. Is this possible to do using just css?
You can use position: absolute and change width and height to 100 vw/vh on hover but to get transition you need first to declare width and height of img.
body { margin: 0; padding: 0; } img { transition: all 0.3s linear; width: 200px; height: 150px; position: absolute; } img:hover { width: 100vw; height: 100vh; } <img src="http://placehold.it/350x150"> I might have used too many CSS properties, but that's merely so I can explain what happens.
// Normal status - without hover img { // Set the position relative to it's parent (body in this case) position: relative; // Automatically calculate distance between the top, left, right and bottom of the window top: auto; left: auto; right: auto; bottom: auto; // Static width/height width: 250px; height: 250px; } // Hovered status img:hover { // Force the image in an fixed position (not respecting other elements) position: fixed; // Make sure it aligns to all sides top: 0; bottom: 0; left: 0; right: 0; // Force it to have the height and width of the viewport (100%) width: 100vw; height: 100vh; }