Electron: Positioning of Window Content


#1

Sorry, don’t really know where to ask this, but I have a website in my electron window, not a local html file. Therefore, I can’t edit the css, but I want to reposition the content in the window (not individual elements, the whole thing). I packaged the app using Nativefier, and there is no css, so again, I can’t edit it. How do I do this? Any help would be appreciated.

Aaron


#2

I think your best bet is running a bit of JavaScript that sets the styles you want to add.


#3

You can inject CSS into a window using the insertCSS method of WebContents.


#4

@enlight Can you give me an example of what it would look like?


#5

mainWindow.webContents.insertCSS('body{background:#222}')

You just need to put that after the URL is loaded. The main issue you’ll have is trawling through Nativefier's Webpacked JS to find where to put it.