views:

75

answers:

1

I want to make simple content page with silverlight with next requirments: Page must contains:

  1. top space for banners(html)
  2. center - silverlight component. and he will stretch to fitt page.
  3. bottom space for banners(html)

Looks quite easy but i faced problem with internet explorer 8. Silverlight component have small size and doesnot stretch. In others browsers its works fine.

Styles:

<style type="text/css">
    html, body
    {
        height: 100%;
        overflow: auto;
    }
    body
    {
        padding: 0;
        margin: 0;
    }
    #silverlightControlHost
    {
        height: 100%;
        text-align: center;
    }
</style>

HTML:

<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" style="overflow: hidden;
    height: 100%; width: 100%;">
    <table  frame="none" cellpadding="0" cellspacing="0" style="height: 100%; width: 100%; border:0px solid White;
        padding: 0px;">
        <tr style="background-color: Red; height: 30px; width: 100%;">
            <td>
            </td>
        </tr>
        <tr style="background-color: Blue; height: 100%; width: 100%;">
            <td>
                <div id="silverlightControlHost" style="height: 100%; width: 100%; background-color: Black;">
                              <object data="data:application/x-silverlight-2," type="application/x-silverlight-2"
                    width="100%" height="100%">
                    <param name="source" value="ClientBin/test.xap" />
                    <param name="onError" value="onSilverlightError" />
                    <param name="background" value="white" />
                    <param name="minRuntimeVersion" value="4.0.50401.0" />
                    <param name="autoUpgrade" value="true" />
                    <a href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;v=4.0.50401.0" style="text-decoration: none">
                        <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Получить Microsoft Silverlight"
                            style="border-style: none" />
                    </a>
                </object>
                <iframe id="_sl_historyFrame" style="visibility: hidden; height: 0px; width: 0px;
                    border: 0px"></iframe>
                </div>
            </td>
        </tr>
        <tr style="background-color: Red; height: 30px; width: 100%;">
            <td>
            </td>
        </tr>
    </table>
</body>

Chrome(works perfect):

alt text

IE8(not so good):

alt text

What wrong with it? How to fix it?

+1  A: 

Hi Evgeny Id stay away from using tables for layout, but thats just me :)

Firstly i would create a holding div for the layout, two divs for the top and bottom and inbetween the silverlight control host div, like

<div id="container">
    <div id="top">
    </div>
    <div id="silverlightControlHost">
        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2"
            width="100%" height="100%">
            <param name="source" value="ClientBin/SilverlightApplication1.xap" />
            <param name="onError" value="onSilverlightError" />
            <param name="background" value="white" />
            <param name="minRuntimeVersion" value="4.0.50826.0" />
            <param name="autoUpgrade" value="true" />
        </object>
        <iframe id="_sl_historyFrame" style="visibility: hidden; height: 0px; width: 0px; border: 0px"></iframe>
    </div>
    <div id="bottom">
    </div>
</div>

what you need to do is switch position to absolute in the silverlightControlHost class, and align the control to stretch over the page, leaving space on top and bottom for your html div containers something like

#silverlightControlHost 
{
    position: absolute;
    top:30px;
    bottom:30px;
    left:0px;
    right:0px;
    text-align:center;
}

and heres the css classes for the other divs

#top
{
   height:30px;
   width:100%;
}

#bottom{
   height:30px; 
   width:100%;
   bottom:0px;
   position:absolute;
} 

#container
{ 
    height: 100%;
    width:100%;
}

Hope that helps

EDIT

it was discovered that bottom was not positioned to the bottom :)

#bottom{
   height:30px; 
   width:100%;
   bottom:0px;
   position:absolute;
} 
almog.ori
Thanks, for quick reply. It really saves a lot of time. Sorry, that maybe such easy question but i new to html. So thanks a lot.
Evgeny
glad to help :)
almog.ori
I set background-color:Red; and noticed, that bottom container actually not at the bottom of the screen. :( How can i move it down?
Evgeny
you are right, ive modified my answer
almog.ori
And one more problem with ie 7. The property height:100% doesnot work at all. Content always not visible! Please help :(
Evgeny
perhaps then set containers class to position:absolute;right:0px;left:0px;top:0px;bottom:0px;
almog.ori
just the same result(
Evgeny
post another question linking to this one, i dont have ie7
almog.ori
found web site with examples: http://limpid.nl/lab/css/fixed/header-and-footer
Evgeny
Add that as an answer its pretty good...
almog.ori