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
In the hive installation directory, enter the con...
1. Introduction This article describes how to use...
There are two ways to install MySQL 5.7. One is t...
There is a task process on the server. When we us...
Attribute check-strictly The official document pr...
When developing applications that use a database,...
Table of contents Compare the empty string '&...
0 Differences between icons and images Icons are ...
This article mainly introduces the full-screen dr...
Previously, https://www.jb51.net/article/205922.h...
1. Go to the GraphVis official website to downloa...
1. Definition of offsetParent: offsetParent is th...
view: Views in MySQL have many similarities with ...
CSS Clear Default Styles The usual clear default ...
WebRTC, which stands for Web Real-Time Communicat...