Negative top margin not working in IE 8 or 9

前端 未结 5 613
悲哀的现实
悲哀的现实 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:04

    If the above doesn't help: make sure there's a div around your offending div. Now add a width of 100% to the offending div and float it to the left. Like this. Got rid of all my negative margin ie woes...

    div.container {}
    div.offender /*inside div.container*/ {
      width: 100%;
      float: left;
      margin-bottom: -20px;   /* ie fix */
      zoom: 1;                /* ie fix */
      position: relative;     /* ie fix */
      display: block;
    }
    

提交回复
热议问题