+ 4

what's the usage of percentage ?

22nd Aug 2016, 8:48 AM
Mahmoud Ramdan Elnazer
Mahmoud Ramdan Elnazer - avatar
3 Antworten
0
percents in CSS are used to scale something in relation to some other factor. In responsive design you might scale your website in relation to the screen, window, or parent container size (width: 90% means 90% of wathever the screen\window\parent width is), or you might scale the font size to whatever the base font size is (a common trick in responsive design to tackle the problem of viewports: Just because a mobile screen has a certain size doesn't mean you know how the website will render since screens my have different pixel density. This way you say: 'I don't care what the pixel valid is, just make it twice as big') In animation, since that what you tagged, you scale in relation to time. it doesnt matter if the animation lasts 2 seconds or 20, it only matters that you start here, end there, and in the middle you want this to happen. This makes it easier to adjust and reuse your animations.
9th Jan 2017, 3:33 PM
Dawid Borusiak
Dawid Borusiak - avatar
- 1
in terms of size -keeps your div within desired scale (responsiveness). CSS media queries area is proportionally divided/queries distributed as you designed regardless the device - mobile tablet PC. there are many other things to do with %
22nd Aug 2016, 11:14 AM
Albert Rosenfield
Albert Rosenfield - avatar