Created
June 21, 2013 02:55
-
-
Save janily/5828510 to your computer and use it in GitHub Desktop.
背景图片自适应
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
$("body").append("<div id='main_bg'/>"); | |
$("#main_bg").append("<img src='bg.jpg' id='bigpic'>"); | |
cover(); | |
$(window).resize(function(){ //浏览器窗口变化 | |
cover(); | |
}); | |
}); | |
function cover(){ | |
var win_width = $(window).width(); | |
var win_height = $(window).height(); | |
$("#bigpic").attr({width:win_width,height:win_height}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment