I’ve got a TABLE that’s actually being used for its intended purpose, to display a grid. The cells are fixed-size cells, with both the width and the height of each cell being constant and defined in CSS.
I can put text and images into the cells easily enough, as long as they fit. But if I try to put an image that’s larger than the cell into a TD, it ends up stretching the cell, and either its entire column or its entire row (or both) depending on which dimension(s) are too big.
I need the table to remain fixed-size, but I also need an image positioned at a specific cell, which is larger than the cell. How should I go about setting this effect up?
To give a simple example:
+---+---+---+
| | | |
+---+---+---+
| | X | |
+---+---+---+
| | X | |
+---+---+---+
Imagine the image is exactly as wide and twice as high as one cell. What do I need to do to make it cover two vertical cells perfectly?
You can use the
max-widthandmax-heightproperties to100%, so that the image doesn’t exceed the cell. Fiddle coming on the way! 🙂HTML
JavaScript
CSS
Preview & Demo
Fiddle: http://jsfiddle.net/4f9K5/1/