How to make Electron WebView fill the specified size?

I tried to add Electron WebView to the base application and set the minimum and minimum load for it, as shown below. When it loads, although it always ends as 784px X 150px

<webview id="webpage" src="https://www.duckduckgo.com/" autosize="on" minwidth="800px" minheight="1200px"></webview> 
+5
source share
1 answer

This is a problem that other people have also reported, here on the atom’s discussion page under the heading β€œView Web Browser”:

https://discuss.atom.io/t/webview-autosize/16915/6

It seems that "autosize" does not say the last word about the resulting window size; The css options can interfere and modify the result.

For this problem, some css workarounds are suggested that may help:

-Remove html and body width up to 100%:

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

-set relative view units in webview css:

 webview { display: block; /* iframes are inline by default */ border: none; /* Reset default border */ height: 80vh; /* Viewport-relative units */ width: 95vw; 

}

+6
source

Source: https://habr.com/ru/post/1241654/


All Articles