我希望使用silverlight制作简单的内容页面以及下一个要求: 页面必须包含:
看起来很容易,但我遇到了Internet Explorer 8的问题。 Silverlight组件尺寸小,不会拉伸。在其他浏览器中,它的工作正常。
样式:
<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&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(效果很好):
IE8(不太好):
它有什么问题?如何解决?
答案 0 :(得分:2)
我远离使用表格进行布局,但仅此而已:)
首先,我会为布局创建一个持有div,顶部和底部的两个div以及silverlight控制主机div之间,如
<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>
你需要做的是在silverlightControlHost类中将位置切换为绝对值,并将控件对齐以在页面上拉伸,为html div容器的顶部和底部留出空间
#silverlightControlHost
{
position: absolute;
top:30px;
bottom:30px;
left:0px;
right:0px;
text-align:center;
}
并且继承了其他div的css类
#top
{
height:30px;
width:100%;
}
#bottom{
height:30px;
width:100%;
bottom:0px;
position:absolute;
}
#container
{
height: 100%;
width:100%;
}
希望有所帮助
修改强>
发现底部没有放在底部:)
#bottom{
height:30px;
width:100%;
bottom:0px;
position:absolute;
}