2015-09-06 19 views

回答

1

好了,解決辦法是使用由特克爾寫外部函數。

他的小數四捨五入功能:https://gist.github.com/terkel/4373420

使用

.tile { 
    &-1-3 { 
    width: decimal-ceil(100/3, 5); 
    // this should result as 33.33334%; 
    } 
    &-2-3 { 
    width: 2/3 * 100%; 
    } 
    &-1-1 { 
    width: 3/3 * 100%; 
    } 
} 
1

你必須使用滾乘法,除法和ceil()自己的舍入方法。

.tile { 
    &-1-3 { 
    $num: 1/3; // 0.33333 
    // the number we multiply by should have the same number of 
    // zeros as there are decimal places you want to keep + the 
    // number of digits there will be on the left side of the decimal 
    $num: $num * 10000000; // 3333333.33333 
    // ceil to round up 
    $num: ceil($num); // 3333334 
    // divide by that amount again 
    $num: $num/10000000; // 33.33334 
    width: $num * 100%; // 33333.34% 
    } 
}