dynamic - CSS: Position child indepently from parent without using position:absolute -


i created css hover menu 1 level.

html

<div id="menu">   <ul>     <li id="item1">item1       <div id="content1"> </div>     </li>     <li id="item2">item2       <div id="content2"> </div>     </li>     <li id="item3">item3       <div id="content3"> </div>     </li>   </ul> </div> 

css

html, body {     margin: 0;     height: 100%;     width: 100%; } #menu {     width: 0%;     padding-left: 16px;     height: 100%;     background-color: red; } #menu:hover {     width: 20%; } #content1, #content2, #content3 {     width: 300%;     height: 1000%;     margin-left: 100%;     background-color: green;     visibility: hidden;     left:16px; } #item1:hover #content1, #item2:hover #content2, #item3:hover #content3 {     visibility: visible; } ul {     list-style: none;     padding: 0;     margin: 0;     height: 100%;     width: 100%; } #item1, #item2, #item3 {     width: 100%;     height: 10%;     display:none; } #menu:hover #item1, #menu:hover #item2, #menu:hover #item3 {     display:block; } 

http://jsfiddle.net/6bv6c/12/

the menu hidden @ first show when hover on it. content boxes show, wenn hover on menu items. problem is: content boxes (green background) show @ same position (top:0 relative body; left:/width of #menu/) , not relative parents (#item1,2,3). elements should maintain dynamic width , height.

is possible css? if not use jquery or js?

cheers!

i used position:absolute solve problem. absolutely positioned item calculates its' point of reference closest parent position:relative style. updated fiddle changes can see mean: http://jsfiddle.net/6bv6c/13/


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -