css 如何设置 margin-top 最小值?

代码:

#div1 {
    min-height:50px;
    background-color: #fee;
    margin-bottom:-50px;
}
#div2 {
    margin-top:50px;
    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

https://stackoverflow.com/a/37433367/3054511

猜你喜欢

转载自blog.csdn.net/henryhu712/article/details/88021716