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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I force my table cell to have a specific width always.

Status
Not open for further replies.

jagi

Programmer
Mar 13, 2005
48
US
Hi,

I have a table inside a div. The division has intial width. If the table stretches beyond this width, the division should get a horizontal scrollbar. And the width of the table cells should not change their width.

But whats happening is that the cells are getting compressed.

I was able to achieve the same, in a similar table which has a header. And i set the header th cells to a specific width, and they never compress - only the divison stretches.

But in the current case, I do no have a header for the table.

Any ideas ?

Thanks.
 

Give your div a style of overflow:auto (of you want the scrollbars to appear when needed), over overflow:scroll (if you want them always to be there):

Code:
<html>
<body>
	<div style="width:120px; height:100px; background-color:red; overflow:auto;">
		<table width="100" border="1" style="background-color:green;">
			<tr><td>abc</td></tr>
		</table>
	</div>
</body>
</html>

In this case, make the div a smaller width, or the table bigger, and you'll get a scrollbar.

Hope this helps,
Dan


The answers you get are only as good as the information you give!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top