616 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 10 000 and 50 000 dollars
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?

2024 posts
  • Elite Author
  • Author had a Free File of the Month
  • Has been a member for 4-5 years
  • Austria
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Envato Studio (Microlancer) Beta Tester
+3 more
revaxarts says

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

616 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 10 000 and 50 000 dollars
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.

2024 posts
  • Elite Author
  • Author had a Free File of the Month
  • Has been a member for 4-5 years
  • Austria
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Envato Studio (Microlancer) Beta Tester
+3 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)

616 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 10 000 and 50 000 dollars
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.

1081 posts
  • Forum Superstar
  • Most Wanted Bounty Winner
  • Envato Studio (Microlancer) Beta Tester
  • Author had a Free File of the Month
  • Bought between 50 and 99 items
  • Referred between 50 and 99 users
  • Europe
  • Has been a member for 3-4 years
  • Exclusive Author
+1 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;
}
616 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 10 000 and 50 000 dollars
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..

491 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Won a Competition
  • Referred between 1000 and 1999 users
  • Author had a Free File of the Month
  • Author had a File in an Envato Bundle
  • Bought between 10 and 49 items
+3 more
pixelentity says

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

127 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Exclusive Author
  • Norway
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%;}
616 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 10 000 and 50 000 dollars
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