Html 在表格单元格中,将画布元素居中,但不将其同级元素居中
我有以下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&
<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%;
}