Deteksi lebar layar dan atur ID ke lebar div bingkai. Sesuaikan sesuai dengan lebar maksimum halaman web Anda. Lebar maksimum demo kecil adalah 1440
Salinan kode adalah sebagai berikut:
<! Doctype html public "-// w3c // dtd xhtml 1.0 transisi // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "konten tipe" content = "text /html; charset = utf-8" />
<title> unt judul dokumen </iteme>
<skrip src = "js/jQuery.min.js" type = "text/javascript"> </script>
<script>
fungsi onwidthchange () {
var w = $ (window) .width ();
x = (W-1440)/2;
$ ("#frame"). CSS ("lebar", w);
if (w <1024) {
$ ("#frame"). CSS ("overflow", "visible");
$ ("#WebContent"). CSS ("margin-left", x);
} lain jika (1024 <w <1440) {
$ ("#frame"). CSS ("overflow", "Hidden");
$ ("#WebContent"). CSS ("margin-left", x);
}
setTimeout (onwidthchange, 0);
};
</script>
</head>
<body>
<Div id = "frame" style = "overflow: hidden;">
<Div id = "WebContent">
//isi
</div>
</div>
</body>
</html>