2 <script type=
"text/javascript">
4 function setNegativeMargin(element
)
6 document
.getElementById(element
).style
["margin"] = "-10px 0px -10px 0px";
9 function setPositiveMargin(element
)
11 document
.getElementById(element
).style
["margin"] = "10px 0px 10px 0px";
16 setNegativeMargin("bar");
18 // The following line forces a layout in Safari.
21 setNegativeMargin("foo");
22 setPositiveMargin("bar");
26 <body onLoad=
"test();">
27 <p>What it should look like (positive case):
</p>
28 <div style=
"border: 1px solid green; ">
29 <div style=
"margin-top: 10px; border:1px solid blue;">Lorem ipsum
</div>
30 <div style=
"margin-top: 10px; margin-bottom: 10px; border:1px dotted blue;">Lorem ipsum
</div>
33 <p>What it should look like (negative case):
</p>
34 <div style=
"border: 1px solid green; ">
35 <div style=
"margin-top: 10px; border:1px solid blue;">Lorem ipsum
</div>
36 <div style=
"margin-top: -10px; margin-bottom: -10px; border:1px dotted blue;">Lorem ipsum
</div>
38 <p>Dynamic case (automatically testing positive --
> negative):
</p>
39 <div style=
"border: 1px solid green; ">
40 <div style=
"margin-top: 10px; border:1px solid blue;">Lorem ipsum
</div>
41 <div style=
"margin-top: 10px; margin-bottom: 10px; border:1px dotted blue;" id=
"foo">Lorem ipsum
</div>
44 <input type=
"submit" value=
"Negative margin" onClick=
"setNegativeMargin('foo');"/>
45 <input type=
"submit" value=
"Positive margin" onClick=
"setPositiveMargin('foo');"/>
46 <p>Dynamic case (automatically testing positive --
> negative --
> positive):
</p>
47 <div style=
"border: 1px solid green; ">
48 <div style=
"margin-top: 10px; border:1px solid blue;">Lorem ipsum
</div>
49 <div style=
"margin-top: 10px; margin-bottom: 10px; border:1px dotted blue;" id=
"bar">Lorem ipsum
</div>
52 <input type=
"submit" value=
"Negative margin" onClick=
"setNegativeMargin('bar');"/>
53 <input type=
"submit" value=
"Positive margin" onClick=
"setPositiveMargin('bar');"/>