I have made a div and I have given it position: fixed using this style sheet:
CSS
position: fixed;
top: 35px;
z-index: 9999;
height:60px;
background:#000;
width:100%;
Now what I want is:
if this div has height zero, then the div which is just after should come in place of the above div.
if the height of div is not zero, the next div after this div should have a margin from the above div so both div will not overlap each other.
When you have an element that is fixed (or absolute), there is no element after it. The fixed element is taken out of the document flow.
If you want two elements after each other at a fixed position, make a container that is fixed, and put the two elements inside it.
You can put another container with a top-margin around them, and set a top-margin on the second element. If the first element is empty, there is nothing to have a margin to, so the margin will collapse outside the container and the second element will be at the top of the container.
(The second container is needed because the margin will not collapse outside the fixed element.)
Demo: http://jsfiddle.net/Guffa/r5crS/