Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome does not re-calculate width when height changes

Tags:

css

I have a list of thumbnails with links and images, so when the user hover an li element, it's height becomes 100%, but the problem it works wrong in Chrome for some odd reason. I don't understand why in Chrome the hovered li width doesn't adjust to its "new" size.

(Note: this is a simplified version of my problem)

Also, this problem occurs only on :hover. but not, lets say, with :nth-child

Playground link

chrome vs FF

Update: problem continues...

See my solution in the answers, BUT the problem continues..I've zoom in with the mouse and you will see it happening..note that number of images can be huge.

Update 2:

Force a redraw every mousehweel event fires... thumbs.hide().show(0);

like image 666
vsync Avatar asked Feb 05 '13 22:02

vsync


1 Answers

My solution: Solution playground

The idea is to trick Chrome to re-calculate the width, by giving the image a new height that is almost the same on the li:hover state. BUT this isn't enough for Chrome. transitions must also be applied on the img. This is all voodoo coding, but this is the least-ugly solution I could come up with:

ul{ list-style:none; display:inline-block; height:80px; white-space:pre; width:100%; }
  li{ display:inline-block; vertical-align:middle; height:60%; -webkit-transition:.2s; transition:.2s; }
  li:hover{ height:100%; }
    li a{ height:100%; padding:0 2px; display:block; }
    li a img{ height:96%; -webkit-transition:.2s; transition:.2s; }
    li:hover a img{ min-height:96%; }
like image 100
vsync Avatar answered Sep 28 '22 06:09

vsync