您的位置:首页 > 其它

一般活动页面之类简单的背景图内容布局方式

2016-08-18 15:23 274 查看
css:

.bg { width: 100%;height:auto; }

.content{width:100%;min-height:100px;}

html:

<div id="img_bg"><img class="bg" src="/zhannew/statics/images/cdz/red-input-bg.png" ></div>

<div class="content"></div>

js:

addLoadEvent(layoutFix);

function layoutFix(){

  var img_height = $('.bg').height();
$('.content').height(img_height);
$('.content').css('margin-top','-'+img_height+'px');

}

function addLoadEvent(func) {
var old_onload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
}
else{
old_onload();
func();
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: