我有一个问题,我无法弄清楚如何纠正这个问题.我想要的是"红色框"在z-index 2中保留在页面顶部,而背景上的所有内容都保留在索引1上但不知何故这个代码"折叠"了图层.如果有人可以帮助我,我真的很感激.对不起我的英语不好.提前致谢.
<html>
<head>
<title></title>
<style type="text/css">
body { margin: 0; }
#container {
position: absolute;
float: right;
z-index: 1;
}
.left1 {
background-color: blue;
height: 50px;
width: 100%;
}
.left2 {
background-color: green;
height: 50px;
width: 100%;
}
#right {
background-color: red;
height: 300px;
width: 300px;
float:right;
z-index: 999999;
margin-top: 0px;
position: relative;
}
</style>
</head>
<body>
<div id="container"></div>
<div class="left1">LEFT BLUE</div>
<div class="left2">LEFT GREEN</div>
</div>
<div id="right">RIGHT RED</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我正在努力使文本保持在可调整大小的DIV中间.这是一个例子:
CSS
#rightmenu {
position: absolute;
z-index: 999999;
right: 0;
height: 60%;
text-align: center;
}
Run Code Online (Sandbox Code Playgroud)
HTML
<div id="rightmenu">This text should be center aligned and in the middle of the resizable rightmenu</div>
Run Code Online (Sandbox Code Playgroud)
我试图让一个Class包含带有"margin-top和margin-bottom"的文本都在auto上,但是不起作用.