我正在努力使搜索表单响应。想要制作一个child div absolute
所以我可以将它放在我想要的任何地方。以下是 site ,其中包含div
#search-near
的搜索表单,我希望将其放在第二个导航下方和内容之前。
喜欢这个
答案 0 :(得分:1)
您可以使用nth-child
选择器:
<强> E.g:强>
div:nth-child(1) {
position: absolute;
/* More CSS here */
}
更多信息here。
答案 1 :(得分:1)
问题在于position: absolute;
会将您的元素相对于第一个定位的(非static
)祖先定位,这在您的情况.right-container
中。
position: relative
。.right-container
margin-top: -600px
#search-near
padding-top: 320px
添加#page-content
以使#search-near
某个地方
如果您在页面上有#under-slideshow-box
:
.home-content
。例如。添加position: relative
(如果它尚未以某种方式定位)。直到#search-near
应该具有默认(static
)定位的路径上的元素。.home-content
应该收到填充#search-near
应定位absolute
top: 0