SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    446
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    is there a better alternative to this solution to hiding overflow text in a cell?

    This is the solution I came up with to hiding overflow text in a cell
    HTML Code:
    <td style = "border-left:1px solid #000;border-right:1px solid #000;padding:0px 10px 0px 10px;">
    			<div style="width:200px;overflow:hidden;white-space:nowrap;">abcdefg...</div>
    		</td>
    I couldn't find a way to limit the text in my cell to a short snippet without using a div.

    How would you do that without a div?

  2. #2
    SitePoint Addict AllanP's Avatar
    Join Date
    Sep 2010
    Location
    Australia
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to set max-width for the cell and overflow hidden. For the IE example you need to set the table-layout to fixed. Here is the code.
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    
    <head>
    <title>clip TD</title>
    <style type="text/css">
    table { table-layout:fixed; }
    .maxW { max-width:30px; overflow:hidden; }
    </style>
    </head>
    
    <body>
    
    <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100">
      <tr>
        <td width="70%">&nbsp;</td>
        <td width="30%" class="maxW">abcdefghi</td>
      </tr>
    </table>
    
    </body>
    
    </html>

  3. #3
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    39,784
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    If you just want any content that doesn't fit into a cell to be hidden then you just need the table-layout:algorithm.

    Code:
    table {table-layout:fixed;width:100%; }
    .cellname { overflow:hidden; }
    Unless I misunderstood the question


Bookmarks

Posting Permissions

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