简体   繁体   English

如何在电子应用程序上获得圆角?

[英]How to get rounded corners on an Electron app?

I am currently trying to get rounded corners on an Electron application I'm making.我目前正在尝试在我正在制作的电子应用程序上获得圆角。 I have tried nearly every solution available on-line at the moment, but none of them make any difference.目前我已经尝试了几乎所有在线可用的解决方案,但没有一个有任何区别。

How can I round the corners of my Electron app?如何绕过 Electron 应用程序的四角?

Make a frameless transparent window制作无框透明窗

const myWindow = new BrowserWindow({
    transparent: true, 
    frame: false
})

And have something like this in the renderer, or apply the style directly to the body tag并且在渲染器中有这样的东西,或者直接将样式应用到 body 标签上

<div style="width: 500px; height: 500px; border-radius: 5px">My window content</div>

Just make sure to also add a custom window titlebar that has -webkit-app-region: drag in order to make the window dragable from this element.只需确保添加一个具有-webkit-app-region: drag的自定义窗口标题栏,以使窗口可从此元素-webkit-app-region: drag

Check out the Electron Docs for further informations ;) https://github.com/electron/electron/blob/master/docs/api/frameless-window.md#transparent-window查看电子文档了解更多信息;) https://github.com/electron/electron/blob/master/docs/api/frameless-window.md#transparent-window

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM