CSS 和 TWebbrowser delphi

发布于 2024-10-19 02:15:30 字数 382 浏览 6 评论 0原文

我想知道是否可以操纵网站的 CSS。例如输入字段中的颜色?我查看了几个问题,但我不清楚这是否可能。

例如,在 Google Chrome 中,每当选择一个字段时,它都会在外部站点周围显示一条金色线条。是否可以在 delphi 中通过任何网站执行此操作和其他操作。编写应用于在 Twebbrowser 中打开的网站的 CSS 代码?仅供个人查看,

谢谢

我也可以使用此代码更改输入字段背景的颜色吗?我可以更改背景颜色并更改字体大小,但似乎无法弄清楚输入字段的颜色或边框。这是代码:

http://www.delphidabbler.com/tips/58

I was wondering if it was possible to manipulate the CSS of websites. For example color in the input fields? I had a look at several questions, but its not clear to me if it is possble at all.

For Example in Google Chrome, Whenever a field is selected it shows a golden line around the outsite. Is it possible to do this and other things in delphi, with any website. Writing CSS code that gets applied to the website opend in Twebbrowser? Just for personal viewing only

Thx

Can I change the color of an input field background with this code as well? I can change background colors and change font size, but cant seem to figure out to color in or border an input field. This is the code:

http://www.delphidabbler.com/tips/58

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

自在安然 2024-10-26 02:15:30

加载页面后,可以通过从代码添加样式表来修改 CSS:

var
   document: IHTMLDocument2;
   stylesheet: IHTMLStyleSheet;
   stylesheetIndex: Integer;
begin

   // Inject CSS Style Sheets
   document := webBrowser1.Document as IHTMLDocument2;

   stylesheetIndex := document.styleSheets.length;
   if stylesheetIndex > 31 then
      raise Exception.Create('Already have the maximum amount of CSS stylesheets');

   stylesheet := document.createStyleSheet('', stylesheetIndex);
   stylesheet.cssText := ...

It is possible to modify CSS by adding a stylesheet from code, after the page is loaded:

var
   document: IHTMLDocument2;
   stylesheet: IHTMLStyleSheet;
   stylesheetIndex: Integer;
begin

   // Inject CSS Style Sheets
   document := webBrowser1.Document as IHTMLDocument2;

   stylesheetIndex := document.styleSheets.length;
   if stylesheetIndex > 31 then
      raise Exception.Create('Already have the maximum amount of CSS stylesheets');

   stylesheet := document.createStyleSheet('', stylesheetIndex);
   stylesheet.cssText := ...

猥︴琐丶欲为 2024-10-26 02:15:30

使用 @jasonpenny 的答案添加样式表,接下来需要更改具有焦点的输入元素周围的边框,这在 CSS 中称为焦点伪类或选择器。有关详细信息,请参阅以下文章:

http://www.w3schools.com 站点拥有大量有关 Web 开发的信息。它还允许您尝试许多示例,以便您可以看到更改内容时会产生什么效果。如果您想学习如何进行 CSS 样式设置,那么最好掌握其中的所有信息,而不是尝试同时学习编程和编程语言。

Using @jasonpenny's answer to add a stylesheet, what you need next to change the border around the input element that has focus, is what in CSS is called the focus pseudo class or selector. For more information see these articles:

The http://www.w3schools.com site has a wealth of information on web development. It also allows you to play with many examples so you can see what the effects would be when you change things. If you are trying to learn how to do css styling you might be better of getting to grips with all the information there, instead of trying to learn programming and a programming language at the same time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文