首页 > 解决方案 > 如何让跨度边距留在 div 旁边,并垂直对齐中心?

问题描述

如何让跨度边距留在 div 旁边,并垂直对齐中心?

enter image description here

红色框架是div,绿色框架是span。外部div元素是 div。

    <div>
      <span style="width: 100%; margin: auto auto auto 0;">0台&lt;/span>
    </div>

我试过使用margindisplay:inline-block;都失败了。

我想span搬到那里:

在此处输入图像描述


编辑-1

div是使用 Colspan属性作为宽度。

<Col :span=8>
  <div>
    <span>...
  </div>
</Col>

标签: htmlcss

解决方案


请使用display:tableand进行样式设置display:table-cell

<div style="width: 500px;height:200px;display:table;">
          <span style="width:100%; display:table-cell;
          vertical-align:middle;">0台&lt;/span>
</div>


推荐阅读