• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 157
  • Last Modified:

Controlling the width of table columns

Hi,

I need to control the width of columns in a table. The default behavior of IE is to adjust the size of the table columns to fit in the window. I need to specify a fixed size for the column of my table and if the total size of all columns exceeds the size of the window, a scrollbar should appear to allow the user to scroll.

To do so, I created a frameset and placed my table in a frame. I specified that the frame should scroll if required.

I included the source code for both the frameset and the frame below.

In the table, I specify that the width of each column in pixels. No scrollbar is ever created and the width of each column is decreased by the browser.

Any help is appreciated.

******** FRAMESET **********
<HTML>
<HEAD>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<TITLE>Example </TITLE>
</HEAD>


<FRAMESET framespacing=1 border=0 frameborder=0>

    <FRAME  
    SRC="testTable.htm"
    NAME="testTable"
    FRAMEBORDER=0
    SCROLLING=yes
    ALIGN=top
    MARGINWIDTH=1
    >
   
</FRAMESET>

</HTML>

********** FRAMESET **********


********** FRAME testTable.htm ********
<HTML>
<HR SIZE=1 noshade><A NAME="Example_2"></A><B>Example 2</B>

<TABLE BORDER=1 cellpadding=3>
   <TR>      
         <TD WIDTH=400 VALIGN="top">
            Column 1
         </TD>
         
            <TD WIDTH=1200 VALIGN="top">
                  Column 2
            </TD>                  
       
        <TD WIDTH=400 VALIGN="top">  
                  Column 3            
        </TD>                              
   </TR>
</TABLE>
</HTML>

********** FRAME testTable.htm ********

0
rakhras
Asked:
rakhras
1 Solution
 
t1pimpCommented:
Well, you don't actually need to put it in a frameset at all. You could if you were using a frameset for navigation or something, but just for this it's not neccessary.  Set the table width equal to the sum of all your tabledata's.  2000.  

<table width="2000">


ex:
--------------------------------------
<HTML>
<HR SIZE=1 noshade><A NAME="Example_2"></A><B>Example 2</B>

<TABLE BORDER=1 cellpadding=3 width="2000">
   <TR>      
         <TD WIDTH=400 VALIGN="top">
            Column 1
         </TD>
         
<TD WIDTH=1200 VALIGN="top">
Column 2
</TD>                  
         
        <TD WIDTH=400 VALIGN="top">    
Column 3
        </TD>                                
   </TR>
</TABLE>
</HTML>
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now