Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vertical Text

Status
Not open for further replies.

VBmim

Programmer
Jun 25, 2001
361
BE
Hello

I would like to make a table with vertical table headers. Is this possible?

ex:
s s s s
h h h h
o o o o
p p p p
1 2 3 4
------------------------------
art1 | 1 2 1 0
art2 | 4 2 0 3
art3 | 0 0 1 0

Greetz

VBMim
 
In IE at least, you can simulate this quite easily by wrapping your vertical text in a span tag with a small width, and forcing word wrapping:

Code:
<html>
<body>
	<span style="width:1px; word-wrap:break-word;">Shop1</span>
	&nbsp;&nbsp;
	<span style="width:1px; word-wrap:break-word;">Shop2</span>
</body>
</html>

I've not tried this in other browsers, however.

Hope this helps,
Dan
 
The simplest way: write s<br>h<br>o<br>p<br>X<br> in header cells :)

In IE you can also use writing-mode property. This will rotate letters by 90 degrees, though:
Code:
<style type="text/css">
.foo th
{	writing-mode: tb-rl;
}
</style>

<table class="foo">
<tr>
		<th>shop1</th>
		<th>shop2</th>
		<th>shop3</th>
		<th>shop4</th>
</tr>
<tr><td>1</td><td>2</td><td>1</td><td>0</td></tr>
<tr><td>4</td><td>2</td><td>0</td><td>3</td></tr>
<tr><td>0</td><td>0</td><td>1</td><td>0</td></tr>
</table>
If that's not good enough try some javascript:
Code:
<body onload = "initTables()">
...
<script language="javascript">
function initTables()
{	var aTables = document.getElementsByTagName("TABLE");
	for (i=0; i< aTables.length; i++)
		if( (oTab = aTables[i]).className == "foo" )
			for( oRow = oTab.rows[0], j=0; j< oRow.cells.length; j++ )
			{	sCell = oRow.cells[j].innerHTML;
				for( sNew = "", k=0;k<sCell.length; k++)	sNew+= sCell.substr(k, 1) + "<br>";
				oRow.cells[j].innerHTML = sNew;
			}	
}
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top