我正在尝试创建一个布局,在其中导航位于图像上方的div中。 我使用z-index来实现这一点。 我尝试将图像设置为背景图像,但无法在更改浏览器窗口大小时正确缩放。
z-index似乎正常工作,但现在包含导航的div不再右浮动了。
有解决方法吗?
<head>
<meta charset="UTF-8">
<style type="text/css">
body{
}
#container{
width: 100%;
height: 1000px;
background-color: yellow;
position: relative;
}
#blue{
margin-top: 20%;
width: 50%;
height: 10%;
background-color: blue;
float: right;
position: absolute;
z-index: 10;
}
#test_image{
width: 100%;
position: absolute;
z-index: 5;
}
</style>
</head>
<body>
<div id="container">
<img id="test_image" src="http://i1370.photobucket.com/albums/ag265/arsinek1/web_development/test_zpsfbvzo3ij.jpg">
<div id="blue"></div>
</div>
</body>