[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Stop <TD> contents pushing out table width.

Posted on 2005-04-11
8
Medium Priority
?
279 Views
Last Modified: 2012-05-05
How do I put a large amount of text in a <TD> without it pushing out the table cell width.

For example:
Say the cell contents are: "abcdefghijklmnopqrstuvwxyz", and my cell with is 100px
I want it to display like this with the text in the 2nd table cell:

|--------------1--------------|abcdefghijklmn||--------------3--------------|--------------4--------------|

...with the "opqstuvwxyz" being "hidden" underneath <TD>#3.

This IS possible.
I did have the code (which I viewed-source from a Microsoft site) - but I cant find it anymore.
I think I remember it using a table inside a table, or something like that...
0
Comment
Question by:astromex
  • 4
  • 2
  • 2
8 Comments
 
LVL 32

Expert Comment

by:Batalf
ID: 13753784
The only method I can think of that is crossbrowser is to use a div with overflow set to hidden.

Example:

<style type="text/css">
.width100{
    width:100px;
    overflow:hidden;
}
</style>
<table border="1">
<tr><td><div class="width100">Thissjaksdfhklajhsdfaklshdfaksljhf</div></td></tr>
<tr><td><div class="width100">0123456789012345678901234567890</div></td></tr>
</table>
0
 

Author Comment

by:astromex
ID: 13753963
hmmm, that sort of thing, but the example I had before supported variable TD widths - whereas your example is set to 100px.
(in other words the div with is set to 100% of the TD width, so if you resize the browser window, you can reveal more/less content)

I tried setting with the div width to % instead of px, but that didnt work - any ideas?
0
 

Author Comment

by:astromex
ID: 13753990
I remember the nested tables had a lot to do with it - each TD had a table inside it (I wish I could find the original code sample!!)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Accepted Solution

by:
bruno earned 1000 total points
ID: 13754100
>>whereas your example is set to 100px

Batalf's example used 100px because that's what you stated in your question....


try something like this:


<style type="text/css">

table {
    width: 100%;
    table-layout: fixed;
}

td {
    width: 25%!important;
}

.overflow {
    overflow: hidden;
    color: red;
}
</style>




<table border="1">
<tr>
    <td>hello</td>
    <td>hello</td>
    <td class="overflow">
    abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
    </td>
    <td>hello</td>
</tr>
</table>
0
 

Author Comment

by:astromex
ID: 13754202
brunobear, thats spot on. I used 100px as an example because the alphabet wouldnt fit in 100px with the EE font - but sorry I should have been more specific.

Are you guys happy to split the points, or what???
0
 
LVL 32

Expert Comment

by:Batalf
ID: 13754210
No, give brunobear the points. His comment solved your problem

Batalf
0
 

Author Comment

by:astromex
ID: 13754237
OK Batalf, Many thanks for your help!
0
 
LVL 18

Expert Comment

by:bruno
ID: 13754563
Batalf you certainly deserved points here - I can make it up to you with some extra points in one of the PHP questions i asked.  :-)


astormex, glad we could help!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question