http://codepen.io/axlpl/pen/vEOyqLのようなものを作成しています が、ブラウザのサイズを変更すると、右のサイトが 1 行ではなく左の下に表示されることがあります。Sass 関数 vw では、procent を取得する関数、最初の引数 "$size" でそのプロジェクト サイズ、ここでは 1200px を取得し、2 番目の引数で "$target" の要素サイズを取得しました (プロジェクト サイズ 1200px の例)。
HTML
<div class="wrapper">
<div class="left--green"></div>
<div class="right">
<div class="block--red"></div>
<div class="block--black"></div>
<div class="block--blue"></div>
<div class="block--yellow"></div>
</div>
</div>
SASS
@function vw($size, $target) {
$vw: $size / 100;
@return ($target / $vw) * 1rem;
}
.wrapper {
width: vw(1200, 400);
height: vw(1200, 200);
float: left;
}
.left,
.right {
width: vw(1200, 200);
height: vw(1200, 200);
float: left;
display: block;
&--green {
@extend .right;
background: green;
}
}
.block {
height: vw(1200, 100);
width: vw(1200, 100);
float: left;
&--red {
@extend .block;
background: red;
}
&--blue {
@extend .block;
background: blue;
}
&--yellow {
@extend .block;
background: yellow;
}
&--black {
@extend .block;
background: black;
}
}
JS
function viewport() {
var e = window, a = 'inner';
if (!('innerWidth' in window )) {
a = 'client';
e = document.documentElement || document.body;
}
return { width : e[ a+'Width' ] , height : e[ a+'Height' ] };
}
function updateVw(){
var vw = (viewport().width/100);
if(vw % 2) {
console.log('tak');
} else {
console.log('nie');
}
jQuery('html').css({
'font-size' : vw + 'px'
});
}
updateVw();
jQuery(window).resize(function(){
updateVw();
});