WebBrowser样式不能在WinForms中正确应用
本文关键字:应用 WinForms 样式 不能 WebBrowser | 更新日期: 2023-09-27 17:54:59
这是我在WinForms应用程序中使用的HTML代码:
<html>
<head>
<style>
#vif {
margin:20px 5px 5px 5px;
background-color:#888;
}
#inf li {
margin-left:40px;
color:#fff;
}
#inf {
margin-top:15px;
padding-bottom:15px;
display:inline-block;
}
</style>
</head>
<body>
<div id="vif">
<div id="inf">
<li>Hello!</li>
</div>
</div>
</body>
</html>
当我亲自保存并使用IE9显示时,它工作正常,但当WebBrowser
使用它时,#inf
上的margin-top
未应用。为什么?这不是我用的IE吗?相同的代码显示不同!
正确的渲染应该有一个灰色框,周围有边框,白色文本应该固定在中间。
如何使用WebBrowser
正确显示
将以下内容添加到HTML的header部分:
<meta http-equiv="X-UA-Compatible" content="IE=9" >
如果问题确实是兼容性,请参阅这个问题:
WebBrowser控件将使用您安装的任何版本的IE,但出于兼容性原因,它将默认以IE7标准模式呈现页面。
如果你想利用IE9的新功能,你应该在你的HTML页面的
<head>
标签中添加<meta http-equiv="X-UA-Compatible" content="IE=9" />
元标签。