Erkennen Sie die Bildschirmbreite und stellen Sie die ID auf die Div -Breite des Rahmens ein. Passen Sie es an die maximale Breite Ihrer Webseite an. Die maximale Breite der kleinen Demo beträgt 1440
Die Codekopie lautet wie folgt:
<! DocType html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transsitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<kopf>
<meta http-äquiv = "content-type" content = "text /html; charset = utf-8" />
<title> bis zum Titel "Dokument" </title>
<script src = "js/jQuery.min.js" type = "text/javaScript"> </script>
<Script>
Funktion onwidthchange () {
var w = $ (Fenster) .width ();
x = (W-1440)/2;
$ ("#Frame"). CSS ("Breite", W);
if (w <1024) {
$ ("#Frame"). CSS ("Überlauf", "sichtbar");
$ ("#webcontent"). CSS ("Margin-links", x);
} else if (1024 <w <1440) {
$ ("#Frame"). CSS ("Überlauf", "versteckt");
$ ("#webcontent"). CSS ("Margin-links", x);
}
setTimeout (Onwidthchange, 0);
};
</script>
</head>
<body>
<div id = "Frame" style = "Überlauf: versteckt;">
<div id = "webcontent">
//Inhalt
</div>
</div>
</body>
</html>