Hello,
I want to display a table with many columns within a fixed width area.
To achieve this I’m using table-layout:fixed, so that the table does not expand to fit the content.
But using fixed table layout is cutting off content. The table has both text and images. I’m able to display the text by using word-wrap property.
I tried using overflow:auto for the table expecting a horizontal scrollbar to appear, but no it doesn’t.
What do I have to do for the horizontal scrollbar to appear?
Hi,
Thank you very much for the reply.
I have a problem that I don’t know the exact pixel width of the div. I can just give percentage width.
So table layout-fixed is a good solution for me. I am able to display the text with word wrapping. I have 2 columns displaying images. The images are getting cut off. I need the horizontal scrollbar for the images to display completely.
I have a problem that I don’t know the exact pixel width of the div. I can just give percentage width.
That will still work. Just give it a percentage width.
You’ll have to provide some working code of the problem that you are having (or a link) because there are so many variables I can’t make a one and for all solution. It all depends on context and exactly what you are doing.
You can see from the code I posted above how it works so you just need to accommodate that setup in your layout.
Hello Paul,
Thank you once again.
I took your solution and applied our setup. But i still don’t get the horizontal scrollbar.
I’m giving some sample code.
You’ll need to remove the width from the table otherwise the content will just get clipped. This may make the browser not use the table:layout:fixed algorithm but I believe it will attempt to do this even without a width.
I don’t see how else it can be done as it seems you want fixed width columns but only when it suits you :).
As an aside you have a lot of broken code above but I assume you just copied it incorrectly. For example the form cannot go between the table tags. All content in a table must be inside the td or th tags (apart from tbody etc and caption). The form has to fit inside one table cell or else surround the whole table.
You don’t have a doctype so all versions of IE weill behave like ie5 and is a bad move. You can’t use 100% height in that way either (see CSS faq on 100% height).
Hi,
Thank you very much for the solution.
I fixed the problem by giving table-layout fixed for the upper level table and it gave me the horizontal scrollbar.
But now i face another problem. When I resize the browser window, the table doesn’t resize. Is it possible to do so?
I think we’d need to see the actual page to take this any further as it’s quite hard to understand all the dynamics that are needed.
If things are causing that many problems then perhaps its time to re-think the design a little. Not everything is possible but I’d need to see the page to say whether it’s feasible or not.