我有一个带有以下代码的整页背景图片:
<html class="full" lang="en">
<body class="full" >
header, footer and content.... Extending beyond the initial view.
</body>
</html>
<style>
.full {
background: transparent url(../img/blur-background.jpg) no-repeat 0 0 fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
</style>
我的问题描述是,
以下是屏幕
原创 - 全屏背景
滚动
部分白色背景
滚动后出现的屏幕背景。请注意,原始背景未扩展。背景图像再次开始/重复。
答案 0 :(得分:0)
我会为你的背景设一个明确的div,例如:
<html>
<body>
<div id="homeScreenBG"></div>
<div id="restOfPage">
header, footer and content.... Extending beyond the initial view.
</div>
</body>
</html>
#homeScreenBG {
position: fixed;
background-repeat: no-repeat;
width: 100%;
height: 100%;
background-image: transparent url(../img/blur-background.jpg) no-repeat 0 0 fixed;
-webkit-background-size: cover;-moz-background-size: cover;-o-background-size: cover; background-size: cover;
}
答案 1 :(得分:0)
最后通过使用CSS和jQuery解决了这个问题。现在它完美无缺。
<强>的mypage.html 强>
<link rel="stylesheet" type="text/css" href="css/full-screen.css" />
<script type="text/javascript" src="js/full-screen.js"></script>
<div data-role="page" data-cache="false">
<div data-role="header">
</div>
<div class="ui-content" data-role="content">
<!-- All content here....... Scrollable content here.... -->
</div>
<div data-role="footer">
</div>
</div>
<强>全screen.css 强>
body {
margin-top: 50px;
margin-bottom: 50px;
background: none;
background-attachment:fixed;
border: 0px;
}
.ui-page {
background-color: #373737 !important; /*Any color based on the data-theme selected*/
}
.ui-content {
background: transparent url(../img/blur-background.jpg);
background-size : 100% 100%;
}
<强>全screen.js 强>
$(document).on("pageshow", function(){
SizeContent();
});
$(window).on("resize orientationchange", function(){
SizeContent();
});
function SizeContent(){
var screen = $.mobile.getScreenHeight();
var header = $(".ui-header").hasClass("ui-header-fixed") ? $(".ui-header").outerHeight() - 1 : $(".ui-header").outerHeight();
var footer = $(".ui-footer").hasClass("ui-footer-fixed") ? $(".ui-footer").outerHeight() - 1 : $(".ui-footer").outerHeight();
var contentCurrent = $(".ui-content").outerHeight() - $(".ui-content").height();
var content = screen - header - footer - contentCurrent;
$(".ui-content").height(content);
}