Home  >  Article  >  Web Front-end  >  Newbie asking for advice: Regarding the problem of positioning and z-index not working, please help me, wait online_html/css_WEB-ITnose

Newbie asking for advice: Regarding the problem of positioning and z-index not working, please help me, wait online_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:39:17879browse

代码如下:


 
  
  
  
  
  
  下拉菜单
  
  
  
 
 


你好,管理员







 

  我想知道比如为什么后一个div不是应该相对于前一个div进行定位的吗,但是现在后一个div却相对于body进行定位,而且z-index也不管用,这是什么问题?


回复讨论(解决方案)

定位是跟父集相对的  你现在下面的那个div在外面  并不在上一个div里面   
so   就会出现这种情况咯
你这样写


    


You can take a closer look at the knowledge of relative positioning and absolute positioning

You use position:relative for the latter div, which does not disrupt the document flow.
The div before it uses position:absolute, which destroys the document flow.
The two divs are not on the same level.

Just a quick question. Isn’t z-index a stacking order?





Just handwritten, for reference, z-index will only work in this case It works

You use position:relative for the latter div. This method does not destroy the document flow.
The div before it uses position:absolute, which destroys the document flow.
The two divs are not on the same level.



absolute (absolute positioning) and relative (relative positioning ), generally speaking, the reference for the positioning of the former is the parent element, and the reference for the latter is its position in the document flow
As for the issue of z-index, you can look up the points to note when using z-index online. , combined with your code, you will know
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn