html - 如何在CSS中控制表格单元格的大小

标签 html css

我正在使用表格创建这样的图表:

enter image description here

这就是我所拥有的: fiddle :https://jsfiddle.net/Wosley_Alarico/e8xmp6oh/

.rotate {
  /* Safari */
  -webkit-transform: rotate(-90deg);
  /* Firefox */
  -moz-transform: rotate(-90deg);
  /* IE */
  -ms-transform: rotate(-90deg);
  /* Opera */
  -o-transform: rotate(-90deg);
  /* Internet Explorer */
  filter: progid: DXImageTransform.Microsoft.BasicImage(rotation=3);
}
body.page.page-id-7.page-template-default.logged-in.admin-bar.wp-custom-logo.debug-bar-maximized.customize-support img {
  width: 100px !important;
}
td {
  /* letter-spacing: inherit; */
  padding-top: 30%;
}
td.column {
  background-color: #99c71b;
  /* max-height: 586px !important; */
}
<table>
  <tbody>
    <tr>
      <td class="column" rowspan="6">
        <p class="rotate">Specialised Businesses</p>
      </td>
    </tr>
    <tr>
      <td>
        <img class="alignnone size-medium wp-image-310" src="http://localhost/sidimaag/wp-content/uploads/2016/09/e-300x244.jpg" alt="e" width="300" height="244" />General Manager</td>
    </tr>
    <tr>
      <td>
        <img class="alignnone size-medium wp-image-310" src="http://localhost/sidimaag/wp-content/uploads/2016/09/e-300x244.jpg" alt="e" width="300" height="244" />
      </td>
    </tr>
    <tr>
      <td>
        <img class="alignnone size-medium wp-image-310" src="http://localhost/sidimaag/wp-content/uploads/2016/09/e-300x244.jpg" alt="e" width="300" height="244" />
      </td>
    </tr>
    <tr>
      <td>
        <img class="alignnone size-medium wp-image-310" src="http://localhost/sidimaag/wp-content/uploads/2016/09/e-300x244.jpg" alt="e" width="300" height="244" />
      </td>
    </tr>
    <tr>
      <td>
        <img class="alignnone size-medium wp-image-310" src="http://localhost/sidimaag/wp-content/uploads/2016/09/e-300x244.jpg" alt="e" width="300" height="244" />
      </td>
    </tr>
  </tbody>
</table>

看起来像这样:

enter image description here

如何使绿色单元格像第一张图片中那样变小并将文本放在一行中?

最佳答案

您应该能够通过将以下内容添加到您的旋转类来执行您想要的操作:

white-space:nowrap;
width:1.5em;         /* whatever width you want */
overflow:visible;

更新的代码片段:

.rotate {
  /* Safari */
  -webkit-transform: rotate(-90deg);
  /* Firefox */
  -moz-transform: rotate(-90deg);
  /* IE */
  -ms-transform: rotate(-90deg);
  /* Opera */
  -o-transform: rotate(-90deg);
  /* Internet Explorer */
  filter: progid: DXImageTransform.Microsoft.BasicImage(rotation=3);
  white-space: nowrap;
  width: 1.5em;
  overflow: visible;
}
body.page.page-id-7.page-template-default.logged-in.admin-bar.wp-custom-logo.debug-bar-maximized.customize-support img {
  width: 100px !important;
}
td {
  /* letter-spacing: inherit; */
  padding-top: 30%;
}
td.column {
  background-color: #99c71b;
  /* max-height: 586px !important; */
}
<table>
  <tbody>
    <tr>
      <td class="column" rowspan="6">
        <p class="rotate">Specialised Businesses</p>
      </td>
    </tr>
    <tr>
      <td>
        <img class="alignnone size-medium wp-image-310" src="http://localhost/sidimaag/wp-content/uploads/2016/09/e-300x244.jpg" alt="e" width="300" height="244" />General Manager</td>
    </tr>
    <tr>
      <td>
        <img class="alignnone size-medium wp-image-310" src="http://localhost/sidimaag/wp-content/uploads/2016/09/e-300x244.jpg" alt="e" width="300" height="244" />
      </td>
    </tr>
    <tr>
      <td>
        <img class="alignnone size-medium wp-image-310" src="http://localhost/sidimaag/wp-content/uploads/2016/09/e-300x244.jpg" alt="e" width="300" height="244" />
      </td>
    </tr>
    <tr>
      <td>
        <img class="alignnone size-medium wp-image-310" src="http://localhost/sidimaag/wp-content/uploads/2016/09/e-300x244.jpg" alt="e" width="300" height="244" />
      </td>
    </tr>
    <tr>
      <td>
        <img class="alignnone size-medium wp-image-310" src="http://localhost/sidimaag/wp-content/uploads/2016/09/e-300x244.jpg" alt="e" width="300" height="244" />
      </td>
    </tr>
  </tbody>
</table>

关于html - 如何在CSS中控制表格单元格的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39746567/

相关文章:

javascript - 坚持使用 jquery 函数来显示和隐藏 css 元素

jquery - 更改 image.map 区域的不透明度

html - slider 背景图像在 Microsoft Edge 上看起来不太好

javascript - 使用 JQuery 将内容包装在两个 div 内的标签中

css - 将 mat-table 设置为使用带有滚动条的屏幕上的剩余空间

css - 推特 bootstrap CSS 移动

html - 如何相对于 DIV 定位固定元素?

html - 为什么我的 DIV 向左清除?

html - 使用 grep 从本地文件中的 HTML 标记中获取文本

php - 将 AV 扫描添加到文件上传站点