How can one make the font size grow bigger on mouse over? Color transitions work fine over time, but the font size switches immediately for some reason.
Sample code:
body p { font-size: 12px; color: #0F9; transition:font-size 12s; -moz-transition:font-size 12s; /* Firefox 4 */ -webkit-transition:font-size 12s; /* Safari and Chrome */ -o-transition:font-size 12s; transition:color 12s; -moz-transition:color 12s; /* Firefox 4 */ -webkit-transition:color 12s; /* Safari and Chrome */ -o-transition:color 12s; } p:hover { font-size: 40px; color:#FC0; }
CSS transitions provide a way to control animation speed when changing CSS properties. Instead of having property changes take effect immediately, you can cause the changes in a property to take place over a period of time.
To change the size of your text with inline CSS, you have to do it with the style attribute. You type in the font-size property, and then assign it a value.
Ems. The em unit sets the font size relative to the font size of the parent element. So, giving text a font-size of 2em will make this text twice the size of its surrounding text. Setting font size in em units is ideal for an inclusive design.
The color transitions fine over time, but the font switches immediately for some dagnabbit reason.
Your font-size
transition is being overwritten by your color
transition.
transition: font-size 12s; /* transition is set to 'font-size 12s' */ transition: color 12s; /* transition is set to 'color 12s' !! */
Instead, you must combine them all into one declaration:
transition: color 12s, font-size 12s;
See: http://jsfiddle.net/thirtydot/6HCRs/
-webkit-transition: color 12s, font-size 12s; -moz-transition: color 12s, font-size 12s; -o-transition: color 12s, font-size 12s; transition: color 12s, font-size 12s;
(Or, just use the all
keyword: transition: all 12s;
- http://jsfiddle.net/thirtydot/6HCRs/1/).
Try set transition for all properties:
-webkit-transition: all 0.3s ease; -moz-transition: all 0.3s ease; -o-transition: all 0.3s ease; -ms-transition: all 0.3s ease;
it is works as well.
OR just font: transition: font 0.3s ease
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With