Negative top margin not working in IE 8 or 9

前端 未结 5 611
悲哀的现实
悲哀的现实 2020-12-14 07:56

I have a div with margin-top:-200px. I want the div to move up/behind the div above it.

Works great in all browsers except IE so far. margin-top:

5条回答
  •  执念已碎
    2020-12-14 08:12

    Negative margin hide the div… Here is trick use zoom:1, position: relative

    Problem:

    .container{
    padding: 20px;
    }
    .toolbar{
    margin-top: -10px ;
    }
    

    in IE red area of toolbar div hide itself. even we are using zoom: 1. to get rid of this problem we need to add position: relative too.

    Solution:

    so your css class will become

    .container{
    padding: 20px;
    }
    .toolbar{
    margin-top: -10px ;
    zoom: 1;
    position: relative;
    }
    

    http://trickyclicks.com

提交回复
热议问题