Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to parallax an img tag rather than background image in a div?

I've come across a number of parallaxing tutorials (this one in particular I'm looking at now: http://net.tutsplus.com/tutorials/html-css-techniques/simple-parallax-scrolling-technique/); however, they all seem to involve a background image in a <div> that's fixed. Is is possible to achieve a similar parallax effect if my image is in a <img> tag?

like image 720
Matt Avatar asked Jun 30 '13 17:06

Matt


People also ask

Should I use background image or IMG tag?

If the image is part of the content such as a logo or diagram or person (real person, not stock photo people) then use the <img /> tag plus alt attribute. For everything else there's CSS background images. The other time to use CSS background images is when doing image-replacement of text eg.

Can I use IMG tag as background image?

The img could also use object-fit: cover; to replicate a background image with background-size: cover; . You can play with the absolute positioning properties top , right , bottom , left . In combination with setting the min-width and max-width to 100% instead of the width and height .

How do you do parallax effect?

To make a parallax effect, every element is moving at a different pace and time. That is how we achieve the illusion of depth, even though we are scrolling in 2D. The rule of thumb moves the “furthest” objects the least, like how it looks in the real world.


1 Answers

Provided you use the same attributes then yeah sure it can

An example of this can be seen here: http://webdesign.tutsplus.com/tutorials/complete-websites/create-a-parallax-scrolling-website-using-stellar-js/

like image 194
Web Develop Wolf Avatar answered Oct 16 '22 14:10

Web Develop Wolf