How do I use css on new Electron Window?

Niklas Klausberger :

I created a new BrowserWindow the following way, but my CSS does not work. How do I apply it to this window?

$("#btn-new-client").click(function() {
            const remote = require('electron').remote;
            const parent = remote.getCurrentWindow();
            const BrowserWindow = remote.BrowserWindow;
            const child = new BrowserWindow({
                height: 400,
                width: 800,
                parent: parent,
                modal: true
            });

            child.loadFile('new/client.html')
        });
Erick :

As in a normal browser, you would need to link your stylesheet in your HTML file (new/client.html). Let's say you have a new/styles.css file in the same folder.

  <!-- inside 'new/client.html' -->
<head>
  <!-- ... -->
  <link rel="stylesheet" type="text/css" href="./styles.css">
  <!-- ... -->
</head>

In your browser window's DevTools, make sure that the link to the stylesheet is correct.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=391011&siteId=1