I have a header that I fix to the top of the page after a set scroll amount, and want to perform a set of CSS transitions on multiple elements within the header when the header becomes fixed:
- the header height shrinks from 100px to 60px
- the header icons shrinks from 50x50 to 25x25
- the header font shrinks from 48px to 36px
#1 works as expected, but #2 and #3 instantaneously change, instead of animating their size, when the scroll target is hit.
I am adding/removing a class .page-header-fixed
to fix/unfix header.
I am applying the following transition in all cases:
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-ms-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
For the header itself (#1), I am using the following selector to fix the header and change the height:
#page-header-wrapper .page-header-fixed {
position: fixed;
height: 60px;
top: 0;
}
while for the other elements (#2 & #3) I am using this
.page-header-fixed .hd-icon {
width: 25px;
height: 25px;
}
.page-header-fixed .hd-center {
font-size: 36px;
}
I expect the .hd-icon
to animate from 50x50->25x25 and .hd-center
to animate from 48px->36px when the header becomes fixed but both change instantaneously. The header height animates from 100px->60px though.
Is there something with multiple concurrent transitions that I'm not doing correctly, or the way I am targeting the elements?
JSFiddle demo here http://jsfiddle.net/9n90802j/