开发者

CSS question how to make one div appear over another?

开发者 https://www.devze.com 2023-03-23 04:14 出处:网络
i want my div of menu to appear on the top left of the div for my header image. The backgrounds used for the menu blocks are transparent and translucent and i want that the image of the header开发者_S

i want my div of menu to appear on the top left of the div for my header image. The backgrounds used for the menu blocks are transparent and translucent and i want that the image of the header开发者_StackOverflow should be visible under through translucent and transparent backgrounds.. How can i do it using css?? the class for div of menu is divmenu and for header is divmainimg


div.divmainimg {
    position: relative;
}

div.divmenu {
    position: absolute;
    top: 0;
    left: 0;
}

Consider changing the class names to mainimg and menu, respectively.


Set position: relative; on the parent object of your menus that you want them to be positioned relative to, and set position: absolute; on the menu divs. Often you can get away without specifying the exact position - if the divs appear in the DOM where you want them to be visually. E.g. this could be enough:

body { position: relative; }

div.menu { position: absolute; }

Edit: Forget about z-index for now - it is rarely needed.

HTH


try to use absolute position, and set a high z-index for the div you want over others..


You could also now Just simply put the div you want to be over the other div inside the div you want to be under for example:

pretend your div class="a" is the one you want on top, Then div class="b" you want on bottom.

that would put A on top then B under it.


I believe what you are wanting is z-index. Rather than explaining it here, just do a Google search for it. It is simple to understand.

0

精彩评论

暂无评论...
验证码 换一张
取 消