Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Electron WebView fill specified size?

I've tried adding an Electron WebView to a basic app and set minwidth and minheight on it as shown below. When it loads though it always ends up as 784px X 150px

<webview id="webpage" src="https://www.duckduckgo.com/" autosize="on" minwidth="800px" minheight="1200px"></webview>
like image 643
bigtunacan Avatar asked Jan 27 '16 20:01

bigtunacan


People also ask

How do I make the electron app full screen?

To make an Electron app run in full-screen mode when it's started, pass the following configuration option when creating the BrowserWindow instance: mainWindow = new BrowserWindow({fullscreen: true});

What is the difference between iframe and webview?

Unlike an iframe , the webview runs in a separate process than your app. It doesn't have the same permissions as your web page and all interactions between your app and embedded content will be asynchronous. This keeps your app safe from the embedded content.

How do electrons maximize a window?

Call mainWindow. maximize() to maximize the window after you create it. Save this answer.

What is BrowserView?

A BrowserView can be used to embed additional web content into a BrowserWindow . It is like a child window, except that it is positioned relative to its owning window. It is meant to be an alternative to the webview tag.


1 Answers

This is an issue other people have reported too. Here in atom discussion webview autosize.

It seems that 'autosize' doesn't say the last word about the resulting window size; css parameters may interfere and change the result.

There are some css workarounds proposed for this issue that may help:

Set html and body width to 100%:

html, body {
   width: 100%;
   height: 100%;
   margin: 0;
   padding: 0;
}

Set viewport relative units in webview css:

webview {
  display: block;   /* iframes are inline by default */
  border: none;     /* Reset default border */
  height: 80vh;     /* Viewport-relative units */
  width: 95vw;
}
like image 74
Nabzi Avatar answered Oct 14 '22 19:10

Nabzi