Results 1 to 12 of 12

Thread: Scroll bar inside a table?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049

    Question Scroll bar inside a table?

    My page consists of tables. I wish to use a scroll bar on my page but only in a certain area inside a table. Is that possible without using frames?

  2. #2
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196
    Code:
    <div>
       <span style="overflow-y:auto;height:450;">
         <table border="0" align="center" >		  	  
           :
           :
          </table>
       </span>
    </div>

  3. #3
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Originally posted by DeadEyes
    Code:
    <div>
       <span style="overflow-y:auto;height:450;">
         <table border="0" align="center" >		  	  
           :
           :
          </table>
       </span>
    </div>
    There's a couple of things I just wanted to point out. 1. You should put that in the div or table and remove the span (as DIV is a block element, and I'm pretty sure you can't put a block element (table) in an inline element (span)). And 2 you need to include a unit other-wise a conforming browser (e.g. Mozilla, opera, will ignore the height). So it should look more like this:

    Code:
     <table border="0" align="center" style="overflow-y:auto;height:450px;">	
       :
       :
      </table>

  4. #4
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196
    RickBull, I just pulled the code from here:
    Code:
    <xsl:template name="showlist">
    <div>
    	<span style="overflow-y:auto;height:450;">
      		<table border="0" align="center" width="50%">
    			<xsl:for-each select="//XMLControl[Name='pageitem' and Type='Text']">
    		  		<tr>
    		  		<td nowrap="true">	
    		  				<xsl:call-template name="Text"/>
    		  			</td>
    		  		</tr>
    		  	</xsl:for-each>
    		  	<tr>
    		  		<xsl:for-each select="//XMLControl[Name='numrecords' and Type='Text']">
    		  			<td>	
    		  				<xsl:call-template name="Text"/>
    		  			</td>
    		  		</xsl:for-each>
    		  	</tr>
    		 </table>
    	</span>
    </div>
    </xsl:template>
    which works fine for me. but then I am writing browser apps so
    I can specify what browser is required.
    With regard to you saying about DIV's being block elements
    and SPAN's being inline, do you know offhand where I can find more info
    about this

    Edit: Just looking back over some of my code and that place above
    is the only one where I used the SPAN in all the others the
    style is in the DIV and there is no SPAN tags at all.
    Placing the style in the TABLE doesn't appear to work for me (IE6)
    Last edited by DeadEyes; Jan 22nd, 2003 at 06:51 AM.

  5. #5
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Ah I see. Well the best place to get info on anything HTML-wise is the HTML 4.01 specs and the section on DIVs and SPANs. This is the bit that says you can only have inline content for spans:


    These elements define content to be inline (SPAN) or block-level (DIV) but impose no other presentational idioms on the content.
    As for the overflow thing not working on table, I think it's prbably because IE is buggy with a lot of CSS. If you test it in Mozilla it should work, but if there's a problem obviously you're right to contain it in a DIV.

  6. #6
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196
    Thanks for the link much appreciated.

  7. #7
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    No problem. If you have the time the whole thing is worth the read. I've learnt quite a lot from it, especially on the tables section - that's one long page

  8. #8
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    interesting, tables aren't suppose to have overflow property. that is why you put the overflow in the div tag.

  9. #9
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Tables are allow to have an over flow propery I think:

    'overflow'
    Applies to: block-level and replaced elements
    Tables are block-level elements aren't they, so technically it should work.

  10. #10
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    I can't find anything that says the table is a block-level element. and I didn't thnik it was.

  11. #11
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Yep it is, here's the quote from the HTML 4.01 DTD:

    <!--================== HTML content models ===============================-->

    <!--
    HTML has two basic content models:

    %inline; character level elements and text strings
    %block; block-like elements e.g. paragraphs and lists
    -->

    <!ENTITY % block
    "P | %heading; | %list; | %preformatted; | DL | DIV | NOSCRIPT |
    BLOCKQUOTE | FORM | HR | TABLE | FIELDSET | ADDRESS">

    <!ENTITY % flow "%block; | %inline;">
    Block is pretty much anything that takes up a whole line, and squeezes anything afterwards onto a new line, which is what a table does.

  12. #12
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    ok, now that we know that it still doesn't do the overflow. not even in Mozilla, granted I am only using 1.1 so not sure about 1.3a. and if IE doesn't do it then I wouldn't worry about ti as IE has 95% of the market.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width