WebGL动画下的HTML内容无法点击

时间:2015-08-05 10:27:25

标签: javascript html css html5

我想弄清楚为什么无法点击或与之交互的WebGL动画下的HTML内容。

请参阅example

目前包含动画的div设置为:

.webgl-glitch {
    position: absolute;
    z-index: 2;
    overflow: hidden;
    opacity: 0.5;
}

..否则根本不会显示。

我尝试过设置z-index:1;标题/容器div上的属性,但这似乎没有帮助。

以下是标题的HTML部分,包括动画div:

<!-- Begin Header animation -->
<div class="webgl-glitch"></div>
<!-- End Header animation -->


<header id="principalheader" class="centerContainer aligncenter fullScreen tintBackground stonebackground" style="z-index:1">
    <div>
        <div class="container">
            <!-- Site logo-->
            <a href="#" class="logo"><img alt="KUBO" src="img/logo.png"></a>
            <!-- Site Principal slogan-->
            <h1>Digital Exploration for the the digital age</h1>
            <!-- Site Resume-->
            <div class="row">
                <div class="hidden-xs col-md-10 col-md-offset-1">
                    <h2>CRAFT experiences that <strong>defy</strong> expectations<br/>
                        CREATE from the the twin <strong>virtues</strong> of inspiration and innovation<br/>
                        BEAUTY in simplicity and complexity <strong>combined</strong> for the best of both worlds</h2>
                </div>
                <div class="col-md-10 col-md-offset-1">
                    <a class="fa fa-angle-down" href="#" data-scrollto="#about"></a>
                </div>
            </div>
        </div>
    </div>
</header>

我注意到的另一件事是,如果我将.web-glitch动画div包装在HTML5画布元素中,它根本不显示?为什么会这样?

目前CSS中我在画布上唯一的属性是宽度:100%;

1 个答案:

答案 0 :(得分:1)

这不是因为WebGL动画,而是因为.webgl-glitch <div>。将一个HTML元素放在另一个上面可以防止单个元素点击它下面的任何内容;它是否透明无关紧要。

对于<canvas>:您放在<canvas>元素中的任何内容都应该是不支持所述元素的浏览器的占位符;如果您的浏览器支持它,那么<canvas>内的任何内容都将被忽略;所以,如果你有这样的事情:

<canvas>
    <h1>Sorry, but your browser does not support the canvas element.</h1>
</canvas>

在不支持画布的浏览器上,消息&#34;抱歉,但您的浏览器不支持画布元素。&#34;将显示给用户;另一方面,支持画布的浏览器不会在canvas标签内显示元素,并且允许画布正常运行。