2

我创建了一个带有窗口的 Chrome 应用程序,但它不可移动。我想让顶部栏(HTML/CSS 样式)允许它移动。我查看了 Chrome 应用程序示例,但找不到使拖动窗口成为可能的代码。

4

2 回答 2

8

我发现了答案,它没有出现在文档中,也不是很明显。它是一个控制它的 CSS 属性。

-webkit-app-region: drag;

没有它,您的无框窗口将无法移动。

重要提示:您希望可单击或可交互的可拖动节点的任何子节点都需要-webkit-app-region: no-drag;其 CSS。

例如:

.myCustomBar {
    position: absolute;
    width: 100%;
    height: 30px;
    -webkit-app-region: drag;
}

.myCustomBarCloseButton {
    position: relative;
    width: 100px;
    height: 30px;
    -webkit-app-region: no-drag;
}
于 2013-10-15T18:59:11.317 回答
-1
    Just add below code in your background.js

    chrome.app.runtime.onLaunched.addListener(function() {
      chrome.app.window.create("frameless_window.html",
        {  frame: "none",
           id: "framelessWinID",
           innerBounds: {
             width: 360,
             height: 300,
             left: 600,
             minWidth: 220,
             minHeight: 220
          }
        }
      );
    })

And follow  https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/frameless-window
    Here you can find the best sample for creating frameless chrome app with the movable window.It's little bit confusing because, after installing it in chrome you can able to create its shortcut on the desktop as well.
于 2015-06-17T06:01:55.413 回答