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
Does your CSS work when you put content in it beforehand? Also, I would change your CSS style into
div.contentClass {
color: red;
font-family: Arial;
font-size: 32;
font-weight: bold;
}
to target it. And it's regular CSS, right? Then it should be properly wrapped in <style type="text/css"> ** your css ** </style>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.