css - Get device size in SASS -


i device width , height in sass. because want create function convert vw / vh in pixel ncompatible platforms.

i write function in less

@w_device:`$(window).width()/100`; @h_device:`$(window).height()/100`;  .vh(@v){     @val:round(@h_device*@v*1px); } .vw(@v){     @val:round(@w_device*@v*1px); } 

anyone have idea how in sass ?

thanks

i think pretty close asking.

@function get-vw($target) {    $vw-context: (1000*.01) * 1px;   @return ($target/$vw-context) * 1vw; } 

usage:

h1 {   font-size: get-vw(72px); } 

since vw 1% of viewport can scale size in px ratio. return value can used other elements. ie: images, backgrounds, etc.

here great article discussing several sass approaches.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

jquery - ReferenceError: CKEDITOR is not defined -

android - Go back to previous fragment -