Why does the following code works perfectly in browsers like Chrome 41, Firefox 36 and IE 10 but doesn't work as expected in the WebBrowser
control in Windows Forms?
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
html, body {
height: 100%;
margin: 0;
padding: 0;
width: 100%;
}
body {
display: table;
}
.my-block {
text-align: center;
display: table-cell;
vertical-align: middle;
}
</style>
</head>
<body>
<div class="my-block">Some text</div>
</body>
</html>
This solution is from this answer (JSFiddle).
this.webBrowser.DocumentText =
"<!DOCTYPE HTML>" +
"<html>" +
"<head>" +
"<style type=\"text/css\">" +
"html, body {" +
"height: 100%;" +
"margin: 0;" +
"padding: 0;" +
"width: 100%;" +
"}" +
"body {" +
"display: table;" +
"}" +
".my-block {" +
"text-align: center;" +
"display: table-cell;" +
"vertical-align: middle;" +
"}" +
"</style>" +
"</head>" +
"<body>" +
"<div class=\"my-block\">Some text</div>" +
"</body>" +
"</html>";
This code gives me the following result:
Why? What am I doing wrong? How can I fix it?
Thanks in advance.