Creating HTML table with vertically oriented text as table header 表头文字方向

AS an old question, this is more like info or reminder about vertical margin or padding in % that takes parent‘s width as reference .

If you use a pseudo element and vertical-padding, you may basicly draw a square box or <td> : http://jsfiddle.net/qjzwG/319/

.verticalTableHeader {
    text-align:center;
    white-space:nowrap;
    transform-origin:50% 50%;
    transform: rotate(90deg);

}
.verticalTableHeader:before {
    content:‘‘;
    padding-top:110%;/* takes width as reference, + 10% for faking some extra padding */
    display:inline-block;
    vertical-align:middle;
}

If you want to keep <td> ith a small width, table-layout:fixed + width might help. http://jsfiddle.net/qjzwG/320/

.verticalTableHeader {
    text-align:center;
    white-space:nowrap;
    transform: rotate(90deg);

}
.verticalTableHeader p {
    margin:0 -100% ;
    display:inline-block;
}
.verticalTableHeader p:before{
    content:‘‘;
    width:0;
    padding-top:110%;/* takes width as reference, + 10% for faking some extra padding */
    display:inline-block;
    vertical-align:middle;
}
table {
    text-align:center;
    table-layout : fixed;
    width:150px
}

If you want table to still be able to grow from it‘s content but not from width of <th> , using a wrapper with a hudge negative margin opposite to dir/direction of document might do : apparently, the closest to your needs, http://jsfiddle.net/qjzwG/320/

<table border="1">
    <tr>
      <th class="verticalTableHeader"><p>First</p></th>
      <th class="verticalTableHeader"><p>Second-long-header</p></th>
      <th class="verticalTableHeader"><p>Third</p></th>
    </tr>
.verticalTableHeader {
    text-align:center;
    white-space:nowrap;
    transform: rotate(90deg);
}
.verticalTableHeader p {
    margin:0 -999px;/* virtually reduce space needed on width to very little */
    display:inline-block;
}
.verticalTableHeader p:before {
    content:‘‘;
    width:0;
    padding-top:110%;
    /* takes width as reference, + 10% for faking some extra padding */
    display:inline-block;
    vertical-align:middle;
}
table {
    text-align:center;
}

HTML from demo and base :

<table border="1">
    <tr>
      <th class="verticalTableHeader">First</th>
      <th class="verticalTableHeader">Second</th>
      <th class="verticalTableHeader">Third</th>
    </tr>
    <tr>
      <td>foo</td>
      <td>foo</td>
      <td>foo</td>
    </tr>
    <tr>
      <td>foo</td>
      <td>foo</td>
      <td>foo</td>
    </tr>
    <tr>
      <td>foo</td>
      <td>foo</td>
      <td>foo</td>
    </tr>
</table>

For older IE , you need to use writing-mode (CSS) :http://msdn.microsoft.com/en-us/library/ie/ms531187%28v=vs.85%29.aspx

REF:

http://stackoverflow.com/questions/6997631/how-to-display-vertical-text-in-table-headers-with-auto-height-without-text-ov

时间: 2024-08-06 21:35:32

Creating HTML table with vertically oriented text as table header 表头文字方向的相关文章

thinkphp中SQLSTATE[42S02]: Base table or view not found: 1146 Table错误解决方法

随手记录下今天在thinkphp3.2.3中遇到的错误SQLSTATE[42S02]: Base table or view not found: 1146 Table 'test.file_info' doesn't exist,之前用pdo连接数据库一直没有问题,今天突然发现报了上述错误,查看了别人的解决方法,都没有解决,后来看了下之前的表名都是小写的,我现在的表名是"file_Info",改为"file_info"后就不报异常了

table与tr td样式重叠 table样式边框变细

<table style="border:1px solid red;border-collapse:collapse;"> border-style 的属性 值 描述 none 定义无边框. hidden 与 "none" 相同.不过应用于表时除外,对于表,hidden 用于解决边框冲突. dotted 定义点状边框.在大多数浏览器中呈现为实线. dashed 定义虚线.在大多数浏览器中呈现为实线. solid 定义实线. double 定义双线.双线

查找idt table 所對應的page table in Linux

#include <linux/kernel.h> #include <linux/module.h> #include <linux/delay.h> #include <linux/string.h> #include <linux/jump_label.h> #include <linux/types.h> #include <asm/pgtable.h> #include <asm/pgtable_64.h&

create table #temptable 临时表 和 declare @bianliang table ()表变量

create table #temptable 临时表 和 declare @bianliang table ()表变量 在开发过程中,经常会遇到使用表变量和本地临时表的情况.下面是对二者的一个介绍: 1. 为什么要使用表变量 表变量是从2000开始引入的,微软认为与本地临时表相比,表变量具有如下优点:  a.与其他变量的定义一样,表变量具有良好的定义范围,并会被自动清除:  b.在存储过程中使用表变量会减少存储过程重新编译的发生:  c.表变量需要更少的锁请求和日志资源:  d.可以在表变量上

table新增一行并循环获取table内值

简单介绍 table新增一行,并获取table标签中所有td的值,通过js将其组装成json格式传给后端存储数据库. 实际操作 1.首先需要在页面html创建talbe标签内容,定义th标题 2.给包含td的tr增加一个属性,例如:type="subdata" 3.在table标签下增加一个按钮,并给其增加一个click事件 html内容 4.在js文件中进行click事件内容的编写,按照th标题数量进行td的拼接,也增加了一个删除行功能 js内容 5.js使用each来进行table

iview Table组件使用过滤器时无法加载表头解决办法

title: iview Table组件使用过滤器时无法加载表头解决办法 date: 2018-10-01 15:08:50 tags: JavaScript 前端 vue iview 所遇到的问题 使用iview搭建社团用人员管理时,Table组件的columns中filters属性设置为Vue data 中的另一个对象 如下: data() { groupFilter: [], memberCol: [ { title: "组别", render: (h, params) =>

Flink 报错 &quot;Could not find a suitable table factory for &#39;org.apache.flink.table.factories.StreamTableSourceFactory&#39; in the classpath&quot;

转自: https://www.cnblogs.com/Springmoon-venn/p/10570056.html 先上代码: table = tablexx.select('*).tablexx.groupBy('x).select('x, xx.count ) tableEnvironment // declare the external system to connect to .connect( new Kafka() .version("0.10") .topic(&q

双击Table表格td变成text修改内容

//先不多说这里上我的页面 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 6 <title>双击td变成text文本框</title> 7 <link rel="

WebDriver获取table的内容(通过动态获取Table单元格的TagName对其innerHTML值进行获取)

import java.util.ArrayList;import java.util.Iterator;import java.util.LinkedHashMap;import java.util.List;import java.util.Map;import java.util.Map.Entry;import org.openqa.selenium.By;import org.openqa.selenium.JavascriptExecutor;import org.openqa.se