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
Preface Sometimes when we view database data, we ...
Table of contents Phenomenon: Port usage: Spellin...
Written in front I have been writing a special to...
1. The proxy_pass directive of the 1.ngx_stream_p...
Table of contents getting Started Data storage Co...
Every visit will generate Cookie in the browser, ...
Preface It is very simple to create a server in n...
This article shares with you the solution to the ...
Preface When we write code, we occasionally encou...
SQL is the main trunk. Why do I understand it thi...
Install MySQL database a) Download the MySQL sour...
The future of CSS is so exciting: on the one hand,...
At the very beginning, let's talk about what ...
MySQL paging queries are usually implemented thro...
1. Download the software 1. Go to the MySQL offic...