There are two solutions: One is CSS, using background-size:cover to achieve the stretching effect of the image, but IE8 and below do not support background-size, so you can use Microsoft's filter effect, but IE6 does not support it. Copy code The code is as follows:body{background:url(bg.jpg) center center;background-size:cover;height:900px;width:100%; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='bg.jpg', sizingMethod='scale');} Another way is to use jQuery, dynamically insert a div in the body, and then include a picture in the div. When the browser window changes size, dynamically set the size of the background picture. Copy code Copy code The code is as follows:$(function(){ $("body").append("<div id='main_bg' style="position:absolute;"/>"); $("#main_bg").append("<img src='bg.jpg' id='bigpic'>"); cover(); $(window).resize(function(){ //Browser window changes cover(); }); }); function cover(){ var win_width = $(window).width(); var win_height = $(window).height(); $("#bigpic").attr({width:win_width,height:win_height}); } |
<<: How to expand the disk space of Linux server
>>: MySQL Interview Questions: How to Set Up Hash Indexes
Table of contents 1. Character Function 1. Case c...
margin:auto; + position: absolute; up, down, left...
Preface Slow query log is a very important functi...
Preface As we all know, the nginx configuration f...
Array Methods JavaScript has provided many array ...
After installing Redis on Linux, use Java to conn...
Organize the MySQL 5.5 installation and configura...
Data Sheet /* Navicat SQLite Data Transfer Source...
Table of contents 1. What is a subquery? 2. Where...
Before I start, let me emphasize that process.env...
Permission denied: The reason for this is: there ...
1. What is an index? An index is a data structure...
JS running trilogy js running code is divided int...
1. Transition Transition property usage: transiti...
Table of contents Preface 1. Overview 2. Read-wri...