我实现了一个动态显示搜索选项的弹出框。我希望该框“ float ”在所有网站内容之上。目前,当显示该框时,它会取代其下方的所有内容并且看起来很糟糕。
我相信我已经尝试将框的 div 的 z-index 设置为高于其余页面内容的 z-index,但仍然没有成功。
最佳答案
您想使用 absolute positioning .
An absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is html
例如:
.yourDiv{
position:absolute;
top: 123px;
}
为了让它工作,父级需要是相对的(position:relative
)
在您的情况下,这应该可以解决问题:
.suggestionsBox{position:absolute; top:40px;}
#specific_locations_add{position:relative;}
关于css - 在页面内容上方 float 一个 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2006134/