Web サイトのデザインが完了したので、レスポンシブ対応にしたいと考えています。サイトを使用してモバイルではできないことが多いので、PC 向けにレスポンシブにする必要があります。
ウィンドウのサイズを変更すると、すべての要素が適切に配置およびサイズ変更されますが、純粋な CSS を使用しているのか、 CSSと JS の両方を組み合わせて使用しているのでしょうか。iCloud
多くのチュートリアルを見つけましたが、それでもうまくいかない理由がわかりませんでした。
http://unstoppablerobotninja.com/demos/resize/
私のhtml構造の例:
<div id="place">
<div id="wrap">
<div id="1"><img src="">this div needs to be responsive</div>
<div id="2"><img src="">this too</div>
<div id="3"><img src="">and this</div>
<div id="4"><img src="">also this</div>
</div>
</div>
現在の CSS スタイル:
#place{
position: relative;
width:3065px;
height:560px;
margin:0px;
}
#wrap,
{
width:975px;
height:480px;
position: absolute;
top:80px;
}
#1{
width:215px;
height:103px;
position: absolute;
left:0px;
top:0px;
background-color:#409da5;
}
#1 img,
{
width: 100%;
height: 100%;
}
window.resizeを使用してウィンドウのサイズ変更を検出し、jQuery を使用して要素のサイズを変更できます。
$(window).resize(function() {
var nh = $("#1")width() / ratio;
$("#1").css('height', nh + 'px');
var nw = $("#1").height() * ratio;
$("#1").css('width', nw + 'px');
});
しかし、これを行う他の方法はありますか?