问答详情
源自:2-1 绘制背景

求助! 画布无法在适应在浏览器正中间

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
    <title>tinyHeart</title>
    <style type="text/css">
        body {
            padding-top:10px;
        }

        .all_bg{
            width:800px;
            height:600px;
            margin: 0px auto;
        }
        #allconvas{
            position: relative;
            width: 800px;
            height: 600px;
            margin: 0px;
        }
        #canvas1{
            position: absolute;
            bottom: 0;
            left: 0;
            z-index: 1;
        }
        #canvas2{
            position: absolute;
            bottom: 0;
            left: 0;
            z-index: 0;
        }
    </style>
</head>
<body>
    <div calss="all_bg">
        <div id="allcanvas">
            <canvas id="canvas1"  width="800"  height="600"></canvas>
            <canvas id="canvas2"  width="800"  height="600"></canvas>
        </div>
    </div>
    </body>
</html>

一直显示在浏览器左下角,而且ui设置应该是画布正中才对,显示却偏右..http://img.mukewang.com/587f840d00018f6f09490728.jpg

提问者:嗟余听鼓 2017-01-18 23:05

个回答

  • 昵称无
    2017-01-20 15:05:28
    已采纳

      #allconvas{

    这里canvas 单词拼写错了,应该是 #allcanvas