683 posts
  • Has been part of the Envato Community for over 4 years
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
ChapterThemes
says

I’m creating a simple image zoom on hover effect with CSS transitions.

It all works well but – when loading the page for the FIRST time in Chrome you see the images zooming in from zero to correct height.

After some testing i came to the conclusion it happens because of my responsive stylesheet sets a max-width:100% to all images. But the max-width needs to be there for my responsive framework.

One solution a came across was to set classes that set the transitions properties to none and remove them with jquery after pageload. But i don’t like to put classes everywhere just for some stupid chrome loading issue.

Anyone with a tip or solution?

2279 posts
  • Became a Top 20 Author of the Month
  • Had an item that became a weekly top seller
  • Created a helpful tool/app using the Envato API
  • Created a helpful tool/app for Envato Market users
+15 more
revaxarts
says

Have you tried to animate the max-width as well?

683 posts
  • Has been part of the Envato Community for over 4 years
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
ChapterThemes
says

Have you tried to animate the max-width as well?

No, the image should just be the size it is without animating it.

It’s an annoying thing in Chrome. I’ve created the following solution for now:

Created a separate class with the css transition properties and that class with a :hover statement with the animating values.

Then with jquery i add the class to the image on hover – which also triggers the :hover of that class after jquery added the class.

There are no performance problems so i think i’ll keep with this one.

2279 posts
  • Became a Top 20 Author of the Month
  • Had an item that became a weekly top seller
  • Created a helpful tool/app using the Envato API
  • Created a helpful tool/app for Envato Market users
+15 more
revaxarts
says

CSS get’s loaded immediately even if the page isn’t loaded. You can try to add the CSS at the very bottom of the page (is allowed since HTML5 – I think)

683 posts
  • Has been part of the Envato Community for over 4 years
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
ChapterThemes
says

I tried but Chrome still executes it making a normal image animate like a slidein animation. Because img has max-width 100% or width 100% to it.

Chrome is the only browser who does that btw.

1362 posts
  • Had an item that became a weekly top seller
  • Has been part of the Envato Community for over 4 years
  • Has sold $40,000+ on Envato Market
  • Has been a beta tester for an Envato feature
+5 more
Smartik
says
Maybe you shoukd disable the transtion for `max-width`?
img {
    transition: max-width 0;
    -moz-transition: max-width 0;
    -webkit-transition: max-width 0;
    -o-transition: max-width 0;
}
683 posts
  • Has been part of the Envato Community for over 4 years
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
ChapterThemes
says

Maybe you shoukd disable the transtion for `max-width`?
img {
    transition: max-width 0;
    -moz-transition: max-width 0;
    -webkit-transition: max-width 0;
    -o-transition: max-width 0;
}

I had my hopes on this solution cuz it sounds quite nice – but unfortunately it somehow disables the whole animation in chrome. Again in chrome only..

501 posts
  • Has referred 1000+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Became a Top 20 Author of the Month
+10 more
pixelentity
says

been there too and solved in very the same way (js)

127 posts
  • Has sold $125,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Became a Top 20 Author of the Month
  • Had an item that became a weekly top seller
+6 more
Veuse
says

Could you not simply add a wrapper around the image with the max-width, and set image to width:100%;?

.image-wrapper { width:100%; max-width:500px;}
.image-wrapper img { width:100%;}
683 posts
  • Has been part of the Envato Community for over 4 years
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
ChapterThemes
says

Could you not simply add a wrapper around the image with the max-width, and set image to width:100%;?
.image-wrapper { width:100%; max-width:500px;}
.image-wrapper img { width:100%;}

Won’t work either because of the img width 100% – found out that chrome animates both the max-width and width.

by
by
by
by
by
by