画面幅を検出し、IDをフレームのDiv幅に設定します。 Webページの最大幅に従って調整します。小さなデモの最大幅は1440です
コードコピーは次のとおりです。
<!doctype html public " - // w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<Meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> un unt ittitled document </title>
<スクリプトsrc = "js/jquery.min.js" type = "text/javascript"> </script>
<スクリプト>
function onwidthchange(){
var w = $(window).width();
x =(w-1440)/2;
$( "#frame")。css( "width"、w);
if(w <1024){
$( "#frame")。css( "overflow"、 "visible");
$( "#webcontent")。css( "margin-left"、x);
} else if(1024 <w <1440){
$( "#frame")。css( "overflow"、 "hidden");
$( "#webcontent")。css( "margin-left"、x);
}
setimeout(onwidthchange、0);
};
</script>
</head>
<body>
<div id = "frame" style = "overflow:hidden;">
<div id = "webcontent">
//コンテンツ
</div>
</div>
</body>
</html>