1,html部分
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);"><strong><span style="font-size:12px;color:#3333ff;">1.用js插入一张图片并控制图片宽高</span></strong></span>
2,js代码
<script type="text/
javascript" src="
jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(function(){
$(".bd").append("<div id='mainbg'/>");
$("#mainbg").append("<img id='im' src='a82a2e72e7af59296db0d63e3d2ecc5e!n1200.jpg' />");
recover();
$(window).resize(function(e) {
recover();
}); // www.jb200.com
});
function recover(){
var winw = $(window).width();
var winh = $(window).height();
$("#im").attr({width:winw, height:winh});
}
</script>
3,css按比例缩放背景图片
<style type="text/css">
.bd{
background-image:url(a82a2e72e7af59296db0d63e3d2ecc5e!n1200.jpg);
background-repeat:no-repeat;
background-size:cover;
}
</style>
<body class="bd">
</body>