初めてレスポンシブ デザインの Web サイトを作成しています。ピクセルとメディア クエリを使用して設定された画像スライダー div があります。幅にアクセスできるようにしたいので、画像スライダーにどこまで移動する必要があるかを伝えることができます。残念ながら、メディア クエリは HTML を変更しないようです。JavaScriptで使用できるように、その情報を取得するための回避策はありますか。
これは、遊ぶための簡単なWebページの例とJSFiddle http://jsfiddle.net/synthet1c/sNbW9/です
<!doctype html>
<html>
<head>
<style>
body{
position:absolute;
background:red;
width:100%;
height:100%;
}
#outer{
position:absolute;
width:80%;
height:80%;
background:red;
background-image:url('http://www.largepictures.net/largepictures/scenery/largepictures_scenery_large_3066.jpg');
background-position: center;
margin:auto;
}
#inner{
width:80%;
height:80%;
background:rgba(255,0,0,0.3)
margin:auto;
margin-top:5%;
}
</style>
<script>
document.getElementById('inner').onclick = function(){
alert(document.getElementById('inner').style.width);
}
</script>
</head>
<body>
<div id="outer">
<div id="inner">click the box to get width</div>
</div>
</body>
</html>