tags:

views:

44

answers:

5

I have created a spreadsheet like web app and now need to have cell size fix so that text inside the cell shouldn't increase the width or height of the cell.

You can view it here http://i56.tinypic.com/4rw948.png.

The cells are basically elements having two columns as and needs to be fixed so that every cell is of equal size. I don't care if the text is cut off due to large number of alphabets.

Update: http://partydesigners.site50.net/Excel%20Like%20App/Index.html

A: 

Maybe try overflow: hidden on the cells.

Radomir Dopieralski
I already tried this but this is not working
Umair Ashraf
You need to set a width.
halfdan
width is basically set on body load event after calculating document width
Umair Ashraf
A: 

There is max-width and max-height to limit size of elements in CSS. You might also want to have a look at overflow: hidden;

halfdan
I tried this also but doesn't work
Umair Ashraf
A: 

You can try the following CSS on the cell:

width: 100px;
max-width: 100px;
min-width: 100px;
overflow: hidden;  // Or scroll if you want the content to be scrollable
dark_charlie
I tired this for height and this is also not working, I want the height and width both fixed.
Umair Ashraf
@Umair What element do you use for the cells? Is it a regular TD?
dark_charlie
yes each cell is <table> having two <td>
Umair Ashraf
A: 

Thats about the border I think. At the runtime, when a cell is selected you are creating a black border. All borders have padding effect. I suggest you to set height and width of selected cells's row minus your border width.

For example;

Think about a 100px wide square. If you add a 2 px width border to this square, it's width will be 104px automaticly. If you want a fixed view of 100px wide square, you need to set it's width 96px and add 2 px width border.

I hope it helps.

scaryguy
I know this is expanding the cell but what if I add more text in the cell than the size of it? It will be expanded I want to stop that expansion.
Umair Ashraf
Pay attention to issue I mention about and do what people say below; I mean use overflow. I think it will work if you take care all of them together.
scaryguy
A: 

Okay I solved the problem myself by putting div inside each td and applying following CSS.

height: 40px;
min-height: 40px;
max-height: 40px;
overflow: hidden;

Anyways, Thanks a ton for your guys responses.

Umair Ashraf