CSS and TWebbrowser delphi

a 夏天 提交于 2019-12-01 00:55:34

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 := ...

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!