views:

51

answers:

3

I have a web page that is laid out in HTML and has some Silverlight imbeded into the main portion. This Silverlight needs to be absolutely positioned on the screen for reasons out side the scope of this question. In order to maintain the flow of the HTML which is statically positioned I wrote the code below.

<div id="div2" style="height:600;width:900;">
    <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
    <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
</div>

I understand that this is a major hack but I'm not sure if there is a better way to handle this. Thank you for any answers.

Aaron

A: 

Couldn't you just put a <div style="margin-top:a lot;">static content goes here</div>?

Brendan Long
A: 

Couldn't you set position:absolute?

antimatter15
To do what, exactly?
Matchu
+5  A: 

Could it be that your CSS is wrong? Heights and widths should be px for reliable rendering.

HTML:

<div id="div2"></div>

CSS:

#div2 { height: 600px; width: 900px; }

Unitless heights are ignored in all browsers for which I tested. (Even IE6 doesn't do it that wrong.)

Matchu
Isn't `px` the default unit if no unit is specified? I remember having read this somewhere but I am not quite sure anymore...
Slauma
If some browsers do this, it's definitely not part of the spec. My copy of Firefox and Google Chrome ignore unitless heights, but maybe Internet Explorer has different behavior.
Matchu
Nope, checked. IE6, IE7, IE8 ignore unitless height.
Matchu
Yes, you are right. Just checked this: According to CSS spec omitting the unit is only allowed if the value is zero. (I confused it with entering Width and Height attributes for ASP.NET controls where you can omit the unit. But then the rendered HTML automatically adds a `px` to the value of the style.) Sorry!
Slauma
No apologies :) I'm sure it's a huge misconception among new CSSers.
Matchu
This was my problem. Thank you! Thank you for not making fun of me when I put in a crap-load of <div> tags. ;)
Aaron Salazar
Specifically, IE allows non-0 unitless lengths in Quirks Mode only. In Standards Mode it ignores them (except in places where unitless lengths have a defined meaning, like line-height).
bobince
Haha. I thought I remembered IE6 behaving that way, but it didn't when I checked - that's why. Thanks!
Matchu