每次要算 px 跟 em 之間的轉換都很麻煩,compass 又不能直接做變數運算(還是可以我不知道?)。總之我比較習慣用的一個 function 如下,邏輯不複雜,使用方法也很簡單易懂,在這提供給大家做個參考 :)
```
@function em($target, $context: $base-font-size) {
@if $target == 0 { @return 0 }
@return $target / $context + 0em;
}
```
詳細使用方法:https://gist.github.com/ijy/1441967
Search
font-size em 在 Why you shouldn't set font-sizes using em - YouTube 的必吃
The first 500 people to sign up using my link will get two free months of Skillshare premium: https://skl.sh/kevinpowell2A lot of people ... ... <看更多>