Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 在表格单元格中,将画布元素居中,但不将其同级元素居中_Html_Css_Canvas - Fatal编程技术网

Html 在表格单元格中,将画布元素居中,但不将其同级元素居中

Html 在表格单元格中,将画布元素居中,但不将其同级元素居中,html,css,canvas,Html,Css,Canvas,我有以下HTML代码: <tbody> <tr> <td> <canvas class="myid_templates_editor_canvas"></canvas> <div>A lot of codes here</div> <div>A lot of codes here</div&

我有以下HTML代码:

<tbody>
     <tr>
         <td>
             <canvas class="myid_templates_editor_canvas"></canvas>
             <div>A lot of codes here</div>
             <div>A lot of codes here</div>
         </td>
     </tr>
<tbody>
但是代码会影响其他元素
。我试过密码:

td > canvas {
    text-align:center;
}

上面的代码没有将我的画布元素居中?我该怎么办?

设置一个固定的
宽度,然后设置
边距:自动
,以及
显示:块
<代码>文本对齐:居中
将使所有内容居中

canvas.myid_templates_editor_canvas {
    width: 200px;
    margin: auto;
    display: block;
}

试试这个:

td {
 text-align:center; 
}

td div {
 text-align:left;
}

table {
 width: 100%;
}
td {
 text-align:center; 
}

td div {
 text-align:left;
}

table {
 width: 100%;
}