0

Here is my code:

<html>
    <head></head>
    <body>
        <div style="width:300px;height:3000px;position:absolute;top:0;left:0;margin-bottom:1000px;background-color:#00f;">
        </div>
    </body>
</html>

The idea is to have a 3000 px high block and then a 1000 px space. But the space is ignored when I test the code in Safari. Works fine in Chrome though. Not sure in IE. What should I do?

Icarus
  • 1,627
  • 7
  • 18
  • 32
leoliang
  • 3
  • 2

3 Answers3

0

Yeah it works, like Robby and Richa have already commented.

But if you want to visally see the "space" try this code (within the body tag of course)

<div style=" width:300px; height:3000px; position:absolute; 
 top:0px; left:0; margin-bottom:1000px; background-color:#00f; ">
</div>
<div style=" width:300px; height:3000px; position:absolute; 
 top:4000px; left:0; margin-bottom:1000px; background-color:#00f; ">
</div>
StealingMana
  • 77
  • 1
  • 1
  • 15
0

I think you wanted space at the bottom of the div. Try this code below:

<div style="width:300px; height:3000px; position:absolute; top:0px; left:0; background-color:#00f; ">
</div>
<div style="width:300px; height:1000px; position:absolute; top:3000px; left:0; background-color:#fff; ">
</div>
Simon Marquis
  • 7,248
  • 1
  • 28
  • 43
0

Add

body { height:4000px; }

I don't know why but Per Set position absolute and margin

margin-bottom will only do anything to an absolutely-positioned element if the element has no top property.

Community
  • 1
  • 1
Wayne
  • 4,760
  • 1
  • 24
  • 24