I have this HTML code:
<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>
我希望将canvas
居中,但不影响td
的其他子元素。所以我尝试了下面的CSS:
td {
text-align:center;
}
但这段代码会影响到其他元素,比如 <div>
。我尝试了以下代码:
td > canvas {
text-align:center;
}
上述代码不能将我的画布元素居中,我该怎么办?