2015-02-10 109 views
2

我想要一个背景图片添加到我的网站,我reskinning各个部分..背景图片放大

问题是,背景图像在缩小。

见下文。

只是创建一个新的CSS分区更好更快..有人可以请建议的语法?

// Sections backgrounds 

var pageSection = $(".home-section, .page-section, .small-section, .split-section"); 
pageSection.each(function(indx){ 

    if ($(this).attr("data-background")){ 
     $(this).css("background-image", "url(" + $(this).data("background") + ")"); 
    } 
}); 

enter image description here

回答

0

CSS

background-size: cover 

background-size: 100% 

应该是你的解决方案。

0

你可以稍微调整一下你的javascript来上课。

var pageSection = $(".home-section, .page-section, .small-section, .split-section"); 
pageSection.each(function(){ 
    if ($(this).attr("data-background")){ 
     $(this).css("background-image", "url(" + $(this).data("background") + ")"); 
     $(this).addClass('full-background'); //adds the class 
    } 
}); 

然后风格得当与CSS

.full-background { 
    background-size: cover; 
} 

但是这是一个CSS3的风格,所以要小心IE8