Skip to content
Advertisement

Keep the height/width ratio of table

I have a simple table design, a square with 3×3 cells -think Rubik’s cube. I want this table’s width to always be 30% of the window and I don’t want the height/width ratio change if the browser window is being resized. Also I want the inner 3×3 cells to be able to keep text and/or images without the symmetry being distorted. Is this possible with only css/javascript? I’ve tried sooooooooo many things but none has been working so far.

EDIT: I’ve added one of my many attempts to solve this below. The code works in Chrome when I try it in the broswer… but not here for some reason. However, it didn’t solve my initial problem so I guess it’s no problem.

JavaScript
JavaScript
JavaScript

Advertisement

Answer

I see what you mean. Let me provide a modified solution from here: html make <td> height proportional to the width

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement