<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 不适用于儿童画布?

      webkit css resize doesn#39;t work with canvas as child?(webkit css resize 不适用于儿童画布?)
      <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 不适用于儿童画布?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                quot;Status Code:200 OK (from ServiceWorker)quot; in Chrome Network DevTools?(“状态码:200 OK(来自 ServiceWorker)在 Chrome 网络开发工具中?)
                What is quot;X-Content-Type-Options=nosniffquot;?(什么是“X-Content-Type-Options=nosniff?)
                SmtpJs API not working! is there any way to send emails using SMTP server with JavaScript or JQuery(SmtpJs API 不工作!有没有办法使用带有 JavaScript 或 JQuery 的 SMTP 服务器发送电子邮件)
                Can I send email using javascript(我可以使用 javascript 发送电子邮件吗)
                Select All the objects on canvas using Fabric.js(使用 Fabric.js 选择画布上的所有对象)
                Crop the image using JavaScript(使用 JavaScript 裁剪图像)

                    <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>
                            <tbody id='MLuwJ'></tbody>
                          <tfoot id='MLuwJ'></tfoot>