<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>基本图形绘制</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
#myCanvas{
border: 1px solid red;
margin: 50px auto;
}
</style>
</head>
<body>
<canvas id="myCanvas" width="500" height="500"></canvas>
</body>
<script type="text/javascript">
</script>
</html>
2 回答
weibo_哆啦A梦有大口袋_0
TA贡献107条经验 获得超146个赞
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>基本图形绘制</title> <style type="text/css"> *{ margin: 0; padding: 0; } #myCanvas{ display: block; border: 1px solid red; margin: 50px auto; } </style> </head> <body> <canvas id="myCanvas" width="500" height="500"></canvas> </body> <script type="text/javascript"> </script> </html>
只有块级元素才能使用,margin: 0 auto进行水平居中
行内元素的水平居中对它的父级使用text-align:center,
解决问题,记得采纳
添加回答
举报
0/150
提交
取消