如何将元素放在另一个元素的顶部?

ivn*_*ivn 9 html css position z-index

我有一个菜单和一个搜索框.我想把搜索框和菜单项一起放.但我的菜单是在一个名为'custommenu'的div中的不同文件中构建的,它使用以下css:

#custommenu {
  position:relative;
  z-index:999;
  font-size: 14px;
  margin: 0 auto;
  padding: 10px 16px;
  width: 918px;
  background-color: #FB0A51; 
  border-top-left-radius: 10px 10px; 
  -moz-border-top-left-radius: 10px 10px;
  border-top-right-radius: 10px 10px; 
  -moz-border-top-right-radius: 10px 10px;
}
Run Code Online (Sandbox Code Playgroud)

而我的搜索框位于一个单独的文件中,如下所示:

 <div class="header">
   some code
   <div class="quick-access">
      some code
   <php echo $this->getChildHtml('topSearch') ?>;
   </div>
 </div>
Run Code Online (Sandbox Code Playgroud)

我尝试将以下内容添加到css文件中,以便搜索框位于菜单的顶部,但它不起作用

 .header .form-search { 
   position:absolute; 
   right:29px;  
   z-index:1000; 
   top: 80px;  
   width:315px;  
   height:30px;  
   padding:1px 0 0 16px; 
 }
Run Code Online (Sandbox Code Playgroud)

搜索框仍隐藏在菜单后面.我想在菜单中设置搜索框.我该怎么做?

编辑:这是div的css,其中包含搜索框,

 .header { width:930px; margin:0 auto; padding:10px; text-align:right; position:relative; z-index:10; border-top:3px solid #3C3C42;}
 .header .quick-access { float:right; width:600px;margin-top:-125px; padding:28px 10px 0 0; }
 .header .form-search { position:relative; top: 100px;left: 300px; z-index:9999; width:315px; height:30px; padding:1px 0 0 16px; }
Run Code Online (Sandbox Code Playgroud)

这就是它现在的样子,(紫色链接 - 快速访问,白盒子是粉红色'custommenu'区域后面的搜索.我想在粉红色区域有白色盒子.所有这些都在里面"标题")

z-index问题o/p

ivn*_*ivn 7

@所有

很抱歉很晚才回复.但是经过一些小小的调整我找到了解决方案.我将标题的z-index设置为比我的custommenu更高的值.由于我的标题包含搜索框,因此搜索框需要具有更高的值才能通过菜单.

代码现在看起来像这样

.header{ position: relative; z-index: 4000; }
 .header search { position: relative; z-index: 99999; }
.custommenu { position: relative; z-index: 1000 ;}
Run Code Online (Sandbox Code Playgroud)

这完美地将我的搜索框放在我的菜单顶部.再次感谢所有帮助过的人.欣赏它.