Thanos Darkadakis Thanos Darkadakis - 2 years ago 431
CSS Question

Is there a css min-top property

Is there any css property like min-height, but for top?
In the example below, when i hide div1 (via javascript), i want div2 to have top:50. Else, to be placed below div1.


<div id='div1'>This div may be hidden</div>
<div id='div2'>This div must not be placed above 50px</div>

Edit: as i answered below

When div1 is not hidden i want div2 to be exactly below div1. imagine div1 as a treeview which can have any height (or even be hidden) and div2 as a paragraph which should always be below 50px

Answer Source

I see that this question has still many views and people are still commenting. Because of the fact that the question is not fully answered, i decided to write here the complete answer:

Appropriate css:

#div1 {
    background-color: #fee;
#div2 {
    background-color: #efe


  • When div1 is hidden, div2 has a top property of 50px
  • When div1 is not hidden:
    • If div1 height is less than 50px, then div2 is placed at 50px
    • If div1 height is more than 50px, then div2 is placed right under div1
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download