在Windows窗体WebBrowser中更改html元素的位置 [英] Changing the position of html elements in Windows Forms WebBrowser

查看:772
本文介绍了在Windows窗体WebBrowser中更改html元素的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Windows窗体WebBrowser控件中更改一个html元素的位置?我已经有了:

pre $ public partial class Form1:Form
{
public Form1()
{
InitializeComponent();
}

private void webBrowser1_DocumentCompleted(object sender,WebBrowserDocumentCompletedEventArgs e)
{
webBrowser1.Document.GetElementById(gpu_notice)。Style =display:none ;
webBrowser1.Document.GetElementById(header)。OuterHtml =;
webBrowser1.Document.GetElementById(ads)。OuterHtml =;
//在这里移动元素the_game
}
}
}

下一步将移动一个元素...

解决方案

您可以通过添加 position 属性为样式就像这样。

  var game = webBrowser1.Document.GetElementById(the_game); 
game.Style + =position:absolute; top:50px; right:20px;;

我会推荐阅读这个,并得到如何使用它。


Is it possible to change the position of one html element in the Windows Forms WebBrowser Control? I already have this:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
        webBrowser1.Document.GetElementById("gpu_notice").Style = "display:none";
        webBrowser1.Document.GetElementById("header").OuterHtml = "";
        webBrowser1.Document.GetElementById("ads").OuterHtml = "";
        // move element "the_game" here
    }
}
}

The next step would be moving an element...

解决方案

You can move the_game element by adding position property to Style like this.

var game = webBrowser1.Document.GetElementById("the_game");            
game.Style += "position: absolute; top: 50px; right: 20px;";

I would recomend to read this and get how to use this.

这篇关于在Windows窗体WebBrowser中更改html元素的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆