Link to home
Start Free TrialLog in
Avatar of graga
graga

asked on

Adjusting HTML table width based on screen resolution

I want to be able to adjust table width in HTML page depending on screen resolution, using the following logic:

if screen width >= 1024 then
   set table.width to 1024
else
   set table width to 100%

please provide code
ASKER CERTIFIED SOLUTION
Avatar of mms_master
mms_master
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of David S.
To clarify what mms_master said...

max-width isn't supported by IE6, but is by IE7 and IE8.

Also JavaScript is only needed for that expression() to be used in IE.
It'd be good if u set the table width in percentage so that it should increase or decrease with the resolution.
@Kravimir

Even though IE7 is supposed to support max-width when I removed the expression() line and tested in IE7 the table still went over 1024px. So did I do something wrong?

@qwerty
The table width is set to 100% unless the browsers clientWidth is > 1024px. So it will increase or decrease with the resolution but have a max width of 1024.
It seems IE7 doesn't support max-width on tables when a width is given. It seems to work fine in IE8.

Thanks for pointing that out.