【发布时间】:2015-04-24 08:22:21
【问题描述】:
我正在尝试将移动应用设计转移到网站中。我需要在不同分辨率的屏幕和窗口大小上将一些元素保留在同一个地方。我对所有定位都使用相对定位,但似乎无法使用 Z-Index 让元素重叠。另一个线程没有回答我的问题,因为我没有使用 JavaScript,所以情况不一样。我怎样才能让它工作? Here is what I am trying to do:
这是我的代码:
/* Font */
@font-face {
font-family: Museo300-Regular;
src: url(Museo300-Regular.otf)
}
/* Nav */
html {
height: 100%
}
body {
background-image: url('images/bg-img.jpg');
font-family: Museo300-Regular, Museo700-Regular;
display: flex;
height: 100%;
align-items: center;
justify-content: center;
}
#wrapper {
position: relative;
}
#wrapper > div {
border-radius: 50%;
width: 960px;
height: 100%;
overflow: hidden;
margin: auto;
position: relative;
}
#wrapper > div#home {
width: 255px;
height: 254px;
position: relative;
top: 50%;
left: 50%;
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
/* IE 9 */
-webkit-transform: translate(-50%, -50%);
/* Safari */
transform: translate(-50%, -50%);
}
#wrapper > div#contact {
width: 255px;
height: 254px;
position: relative;
top: 70%;
left: 40%;
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
/* IE 9 */
-webkit-transform: translate(-50%, -50%);
/* Safari */
transform: translate(-50%, -50%);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Micah Friesen</title>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body id="body">
<!-- page content -->
<!-- Navigation -->
<div id="wrapper">
<div id="home">
<a href="index.html">
<img src="images/homebttn.png" title="Homepage (Here)" />
</a>
</div>
<div id="contact">
<a href="contact.html">
<img src="images/contactbttn.png" title="Contact Me, this also includes Rates" />
</a>
</div>
</div>
</body>
</html>
【问题讨论】:
-
我建议使用引导程序让生活更轻松。