【公式转换】px to em
- Convert pixels to ems using the formula target ÷ context = result
- Use the default browser font size of 16px as the context unless otherwise specified
例子:
1 <!DOCTYPE HTML> 2 <html lang="en-US"> 3 <head> 4 <meta charset="UTF-8"> 5 <title></title> 6 <style> 7 h1{ 8 font-size: 24px; /* 1.500em 24px/16px */ 9 } 10 h1 a{ 11 font-size: 18px; /* 0.750em 18px/24px */ 12 } 13 </style> 14 </head> 15 <body> 16 <h1>Smells Like Bakin <a href="#">taste really delicious</a></h1> 17 </body> 18 </html>