如何将两个画布放在另一个之上? [英] How to place two canvases on top of one another?

查看:155
本文介绍了如何将两个画布放在另一个之上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了类似的主题,但他们都使用绝对定位,将画布放在页面的左上角。我有他们包含在一个div,但我不知道如何让他们正确层。我尝试在CSS中使用绝对和相对定位,但我没有任何运气。

I found similar topics but they all used absolute positioning which placed the canvases at the top left of the page. I have them contained within a div but I'm not sure exactly how to get them to layer properly. I tried using absolute and relative positioning in CSS but I wasn't having any luck.

推荐答案



Do this:

<style>
    #container { position: relative; }
    .canvas { position: absolute; top: 0; left: 0; }
</style>

<div id="container">
    <canvas class="canvas" id="canvas1"></canvas>
    <canvas class="canvas" id="canvas2"></canvas>
</div>

这篇关于如何将两个画布放在另一个之上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆