编辑:我用这个修复了它:
.element{
position: relative;
top: 40%;
transform: translateY(-50%);
width:50%;
margin-left:auto;
margin-right:auto;
}
好的,所以我无法使用 jquery mobile 在我的页面上使用 img 作为背景。
我想要一张图片作为我的背景。但我想不通。
那么我怎样才能让它工作呢?
这是我的 html:
<!doctype html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=false">
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="themes/mobilethemes.min.css" />
<link rel="stylesheet" href="themes/jquery.mobile.icons.min.css" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.3/jquery.mobile.structure-1.4.3.min.css" />
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.3/jquery.mobile-1.4.3.min.js"></script>
<!-- allows to store on desktop for IOS -->
<link rel="apple-touch-icon" href="icon.png" />
<meta name="apple-mobile-web-app-capable" content="yes" />
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>Header</h1>
</div>
<div data-role="content" class="welcome">
Here is my content
</div>
<div data-role="footer">
<h1>Footer</h1>
</div>
</div>
</body>
</html>
我的CSS:
.ui-page, .ui-body-c, .ui-page-active, .ui-overlay-c, .ui-mobile-viewport
{
background: transparent !important;
}
body, .ui-overlay-c
{
background: url('../data/background.png') !important;
background-repeat:repeat-y !important;
background-position:center center !important;
background-attachment:scroll !important;
background-size:100% 100% !important;
}
最佳答案
尝试设置:
background-color: transparent;
子 div 的。
关于jquery - 无法将图像作为背景。手机版,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24852890/