//HTML
//CSS#bg { position: fixed; top: 0; left: 0; min-width: 100%; min-height: 100%;}要么
img.bg { min-height: 100%; min-width: 1024px; width: 100%; height: auto; position: fixed; top: 0; left: 0;}@media screen and (max-width: 1024px) { img.bg { left: 50%; margin-left: -512px; }}要么
//HTML<img src="images/bg.jpg" id="bg" alt="">//CSS#bg { position: fixed; top: 0; left: 0; }.bgwidth { width: 100%; }.bgheight { height: 100%; }//jQuery$(window).load(function() { var theWindow = $(window), $bg = $("#bg"), aspectRatio = $bg.width() / $bg.height(); function resizeBg() { if ( (theWindow.width() / theWindow.height()) < aspectRatio ) { $bg .removeClass() .addClass('bgheight'); } else { $bg .removeClass() .addClass('bgwidth'); } } theWindow.resize(resizeBg).trigger("resize");});


