Chome firing CSS transitions on first pageload ( max-width problem )

683 posts
  • 4 Years of Membership
  • Author Level 5
  • Collector Level 2
  • Exclusive Author
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?

2280 posts
  • Top Monthly Author
  • Weekly Top Seller
  • Community Superstar
  • Industrious API Inventor
+15 more
revaxarts
says

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

683 posts
  • 4 Years of Membership
  • Author Level 5
  • Collector Level 2
  • Exclusive Author
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.

2280 posts
  • Top Monthly Author
  • Weekly Top Seller
  • Community Superstar
  • Industrious API Inventor
+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
  • 4 Years of Membership
  • Author Level 5
  • Collector Level 2
  • Exclusive Author
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.

1368 posts
  • Weekly Top Seller
  • 5 Years of Membership
  • Author Level 6
  • Beta Tester
+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
  • 4 Years of Membership
  • Author Level 5
  • Collector Level 2
  • Exclusive Author
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
  • Affiliate Level 7
  • Author Level 10
  • Collector Level 2
  • Top Monthly Author
+10 more
pixelentity
says

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

127 posts
  • Author Level 8
  • Collector Level 2
  • Top Monthly Author
  • 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
  • 4 Years of Membership
  • Author Level 5
  • Collector Level 2
  • Exclusive Author
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