【问题标题】:How to create rounded corners in electron browserWindow?如何在电子浏览器窗口中创建圆角?
【发布时间】:2017-06-05 23:02:55
【问题描述】:

我到处搜索如何使浏览器窗口的角变圆。

如何实现圆角?

我试过让它透明。但没有任何效果。

她的我的代码:

/**
 * we need to keep a global reference of the window object. If we don't, the
 * window will be closed automatically when the js object is garbage collected
 */
let win

function createWindow () {
  // Create the browser window.
  win = new BrowserWindow({
    width: 1800,
    height: 1000,
    frame: false,
    transparent: true,
    icon: __dirname + 'icon.png'
  })
  
  // and load the index.html of the app.
  win.loadURL(url.format({
    pathname: path.join(__dirname, 'index.html'),
    protocol: 'file:',
    slashes: true
  }))

  // Open the DevTools.
  win.webContents.openDevTools()

  // Emitted when the window is closed.
  win.on('closed', function () {
    /**
     * Dereference the window object, usually you would store windows in an
     * array if your app supports multi windows, this is the time when you
     * should delete the corresponding element.
     */
    win = null
  })
}

【问题讨论】:

  • frame: false, radii: [5,5,5,5] 是我读到的。
  • 这是在哪里添加的? @scoopzilla
  • @scoopzilla 它不起作用

标签: javascript html css window electron


【解决方案1】:

对于透明度,请尝试使用 opacity 属性。范围是0到1

【讨论】:

    【解决方案2】:
    function createWindow () {
       // Create the browser window.
       win = new BrowserWindow({
          width: 1800,
          height: 1000,
          frame: false,
          radii: [5,5,5,5],
          transparent: true,
          icon: __dirname + 'icon.png'
    })
    

    【讨论】:

    • 这没有任何作用。当我试图使角落变圆时。它仍然没有四舍五入。
    • 那我一定是错过了什么。对不起:(
    猜你喜欢
    • 2018-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-24
    • 2017-12-05
    • 2021-03-24
    相关资源
    最近更新 更多