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
One environment Install VMware Tools on CentOS 7 ...
mysql5.5.28 installation tutorial for your refere...
In the past, I only knew how to use the name attri...
Implementation ideas First, create a parent conta...
Preface Generator functions have been in JavaScri...
Table of contents 1. Function debounce 1. What is...
1. About the file server In a project, if you wan...
Table of contents Implementing a search engine ba...
First execute the command: [root@mini61 setuptool...
Preface By default, Nginx logs are written to a f...
Pop-up windows are often used in actual developme...
Let me first explain why the text is not vertical...
Mysql supports 3 types of lock structures Table-l...
This article mainly introduces why v-if and v-for...
1. Introduction This article describes how to use...