使用无填充/边距使空 span 标签显示为全宽/ 

  • 本文关键字:显示 nbsp span 填充 标签 html css
  • 更新时间 :
  • 英文 :


我敢肯定有人在捣乱,但他们让我这么做。

在表中放置一个span标记,span标记中不包含任何内容。以某种方式使span标签宽度为16像素。

没有填充、边距或&nbsp。我认为这根本不可能。有可能吗?这是我的HTML/CSS。

    .test{
        height: 31px;
        width: 16px;
        background-color: red;
     }

        <td>16px wide</td>
        <td><span class="test"></span></td>
        <td>16px wide</td>

简单设置:

.test{
    display: inline-block;
    width: 16px;
}

最新更新