从 Silverlight 添加 insideHTML 不会应用样式
我正在尝试从 Silverlight 导出一些 HTML 内容。我从 DOM 中获取一个 div,然后更改 innerHTML 属性。添加 HTML 后,HTML 不会从页面获取任何样式。
这是 Silverlight 代码
HtmlDocument doc = HtmlPage.Document
HtmlElement div = doc.GetElementByID("divContent");
div.SetAttribute("innerHTML", "Some content");
这是 HTML
...
<style>
contentClass{
color:red;
font-family:Arial;
font-size:32;
font-weight:bold;
}
</style>
...
<div id="divContent" class="contentClass">
</div>
我已经尝试了几种其他方法来完成此任务。我尝试过将子项添加到应用了类名的 div 中。唯一可行的方法似乎是写出与文本内联的样式。
任何帮助将不胜感激。
谢谢,
理查德
I am trying to export some HTML content from Silverlight. I grab a div from the DOM and then change the innerHTML property. Once the HTML is added the HTML does not pick up any styles from the page.
Here is the Silverlight code
HtmlDocument doc = HtmlPage.Document
HtmlElement div = doc.GetElementByID("divContent");
div.SetAttribute("innerHTML", "Some content");
here is the HTML
...
<style>
contentClass{
color:red;
font-family:Arial;
font-size:32;
font-weight:bold;
}
</style>
...
<div id="divContent" class="contentClass">
</div>
I have tried several other ways to accomplish this task. I have tried adding children to the div with class names applied. The only way that seems to work it to write out the styles inline with the text.
Any Help would be much appreciated.
Thanks,
Richard
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您预先将内容放入 CSS 中时,您的 CSS 会起作用吗?另外,我会将你的 CSS 样式更改
为目标它。这是常规的 CSS,对吗?然后应该将其正确包装在
Does your CSS work when you put content in it beforehand? Also, I would change your CSS style into
to target it. And it's regular CSS, right? Then it should be properly wrapped in
<style type="text/css"> ** your css ** </style>