<small id='NO80Z'></small><noframes id='NO80Z'>

    <legend id='NO80Z'><style id='NO80Z'><dir id='NO80Z'><q id='NO80Z'></q></dir></style></legend>
  1. <tfoot id='NO80Z'></tfoot>
      <bdo id='NO80Z'></bdo><ul id='NO80Z'></ul>

      <i id='NO80Z'><tr id='NO80Z'><dt id='NO80Z'><q id='NO80Z'><span id='NO80Z'><b id='NO80Z'><form id='NO80Z'><ins id='NO80Z'></ins><ul id='NO80Z'></ul><sub id='NO80Z'></sub></form><legend id='NO80Z'></legend><bdo id='NO80Z'><pre id='NO80Z'><center id='NO80Z'></center></pre></bdo></b><th id='NO80Z'></th></span></q></dt></tr></i><div id='NO80Z'><tfoot id='NO80Z'></tfoot><dl id='NO80Z'><fieldset id='NO80Z'></fieldset></dl></div>

      webkit css resize 不适用于儿童画布?

      时间:2023-08-02
      <legend id='Vphpn'><style id='Vphpn'><dir id='Vphpn'><q id='Vphpn'></q></dir></style></legend>
    1. <small id='Vphpn'></small><noframes id='Vphpn'>

        <tbody id='Vphpn'></tbody>
      <i id='Vphpn'><tr id='Vphpn'><dt id='Vphpn'><q id='Vphpn'><span id='Vphpn'><b id='Vphpn'><form id='Vphpn'><ins id='Vphpn'></ins><ul id='Vphpn'></ul><sub id='Vphpn'></sub></form><legend id='Vphpn'></legend><bdo id='Vphpn'><pre id='Vphpn'><center id='Vphpn'></center></pre></bdo></b><th id='Vphpn'></th></span></q></dt></tr></i><div id='Vphpn'><tfoot id='Vphpn'></tfoot><dl id='Vphpn'><fieldset id='Vphpn'></fieldset></dl></div>

        <tfoot id='Vphpn'></tfoot>

            <bdo id='Vphpn'></bdo><ul id='Vphpn'></ul>

                本文介绍了webkit css resize 不适用于儿童画布?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                假设下面的 html 和 css 代码片段:

                Suppose the following html and css code snippet:

                #outer {
                  width: 100px;
                  height: 100px;
                  overflow: hidden;
                  resize: both;
                  border: 1px solid black;
                }
                #inner {
                  width: 100%;
                  height: 100%;
                }

                <div id="outer">
                  <canvas id="inner"></canvas>
                </div>

                我希望 div 可以调整大小,而在 Firefox 中,确实如此.然而,在基于 webkit 的浏览器(例如 chrome 和 opera)中,情况并非如此.但是,如果我用 div 替换内部画布,它也可以在那里工作.所以我的问题是:为什么在这种情况下 canvas 元素会阻止外部 div 调整大小?我该如何解决这个问题?

                I would expect the div to be resizeable, and in firefox, it is. However in webkit-based browsers such as chrome and opera, it isn't. If I replace the inner canvas with a div however, it works there too. So my question is: why does the canvas element in this case prevent the outer div from beeing resizeable? And how can I work around this?

                推荐答案

                似乎画布正在处理鼠标事件,阻止调整大小.如果您在画布上考虑 pointer-events:none 它将起作用:

                it seems that the canvas is taking the mouse event preventing the resize. If you consider pointer-events:none on canvas it will work:

                #outer {
                  width: 100px;
                  height: 100px;
                  overflow: hidden;
                  resize: both;
                  border: 1px solid black;
                }
                #inner {
                  width: 100%;
                  height: 100%;
                  pointer-events:none
                }

                <div id="outer">
                  <canvas id="inner"></canvas>
                </div>

                为了更好地说明,稍微减小画布的大小以避免与调整大小的小部件重叠,它也会起作用:

                To better illustrate, decrease the size of the canvas a little to avoid the overlap with the resize widget and it will also work:

                #outer {
                  width: 100px;
                  height: 100px;
                  overflow: hidden;
                  resize: both;
                  border: 1px solid black;
                }
                #inner {
                  width: 100%;
                  height: calc(100% - 10px);
                  background:red;
                }

                <div id="outer">
                  <canvas id="inner"></canvas>
                </div>

                你也可以玩z-index:

                #outer {
                  width: 100px;
                  height: 100px;
                  overflow: hidden;
                  resize: both;
                  border: 1px solid black;
                  position:relative;
                  z-index:0; /* mandatory to create a stacking context and keep the canvas inside */
                }
                #inner {
                  width: 100%;
                  height: 100%;
                  position:relative;
                  z-index:-1;
                  background:red;
                }

                <div id="outer">
                  <canvas id="inner"></canvas>
                </div>

                这篇关于webkit css resize 不适用于儿童画布?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何保护 HTML5/Canvas 游戏中的代码? 下一篇:KineticJS 拖动一个连接线的框

                相关文章

                  <small id='MLuwJ'></small><noframes id='MLuwJ'>

                  • <bdo id='MLuwJ'></bdo><ul id='MLuwJ'></ul>
                    <i id='MLuwJ'><tr id='MLuwJ'><dt id='MLuwJ'><q id='MLuwJ'><span id='MLuwJ'><b id='MLuwJ'><form id='MLuwJ'><ins id='MLuwJ'></ins><ul id='MLuwJ'></ul><sub id='MLuwJ'></sub></form><legend id='MLuwJ'></legend><bdo id='MLuwJ'><pre id='MLuwJ'><center id='MLuwJ'></center></pre></bdo></b><th id='MLuwJ'></th></span></q></dt></tr></i><div id='MLuwJ'><tfoot id='MLuwJ'></tfoot><dl id='MLuwJ'><fieldset id='MLuwJ'></fieldset></dl></div>
                    <legend id='MLuwJ'><style id='MLuwJ'><dir id='MLuwJ'><q id='MLuwJ'></q></dir></style></legend>
                  1. <tfoot id='MLuwJ'></tfoot>