I was looking at the Angular 2 tutorial and this detail in the CSS caught my attention.
What does the dot in ".1em" means or do?
.heroes li:hover {
color: #607D8B;
background-color: #DDD;
left: .1em;
}
I was looking at the Angular 2 tutorial and this detail in the CSS caught my attention.
What does the dot in ".1em" means or do?
.heroes li:hover {
color: #607D8B;
background-color: #DDD;
left: .1em;
}
It's short-hand for 0.1em
, ie. one tenth of an em. In other words, you are not limited to whole numbers (integers).
This isn't quite as useless as it seems. CSS minimizers are becoming common and would reduce this code to
.heroes li:hover {color:#607D8B;background-color:#DDD;left:.1em;}
The leading zero before .1 is just another byte that can go away.
it mean 0.1em but some people wrote it like .1em, it is short cut, like you used in Maths.
EM is a value relative to the font-size of the element.
.1em is 10% of 1em
With no css: 1em == 16px
If the font size changes, 1em = new font-size value.
The dot actually means 0. and CSS put the number after the dot as a decimal of 1. E.g. .1 = 0.1 or .3s = 0.3s
So, the two blocks below act the same:
div {
transition: all .3s;
}
div {
transition: all 0.3s;
}
Which results 300 milliseconds or 0.3 second.