|
|
|
|
![]() ![]() |
Sep 2 2005, 07:03 PM
Post
#1
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 535 Joined: 14-February 05 From: Oslo, Norway Member No.: 3,759 |
Well, I have a table that I don't want to be over 350 pixels in width - even on the largest screens. On small screens, the table will be smaller. But on large screens, I don't want the table to larger than 350 pixels... Is there a way to do that?
|
|
|
|
Sep 2 2005, 07:10 PM
Post
#2
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 302 Joined: 17-June 05 From: Frankfurt, Germany Member No.: 8,358 |
CODE <table width="350"> bla </table> or you can do it in css. ill explain that too if you want me too. |
|
|
|
Sep 3 2005, 08:43 AM
Post
#3
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 535 Joined: 14-February 05 From: Oslo, Norway Member No.: 3,759 |
Duh, of course I know about that. But if I have a table width like that, there will be a horizontal scrollbar on smaller screens. I want that smaller screens have a smaller table (around 300px). And larger screens have 350px. Is that possible?
|
|
|
|
Sep 5 2005, 10:43 PM
Post
#4
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 123 Joined: 5-September 05 Member No.: 11,522 |
I believe that using the CSS property "max-width" you can do that. Just use the following:
CODE <table style="max-width:350px;"> Note that this may not be compatible with every browser since it is defined in CSS2. Hope this helps! |
|
|
|
Sep 5 2005, 10:50 PM
Post
#5
|
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 1,161 Joined: 9-May 05 From: Brisbane, QLD Member No.: 6,818 |
QUOTE(arboc7 @ Sep 6 2005, 08:43 AM) I believe that using the CSS property "max-width" you can do that. Just use the following: CODE <table style="max-width:350px;"> Note that this may not be compatible with every browser since it is defined in CSS2. Hope this helps! Max-width (or max-height) doesn't work in IE. You need to set a percentage width. Work out roughly what proportion of the screen you want to take up and then no matter what size the screen is, it'll always take up the same proportion. So at a viewport of 800px, 350px would be about 45%, so width="45%". |
|
|
|
Oct 1 2005, 05:10 AM
Post
#6
|
|
|
Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software. ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 975 Joined: 25-September 05 From: The dungeon deep below the foundation of trap17 Member No.: 12,251 |
QUOTE(Tyssen @ Sep 5 2005, 02:50 PM) Max-width (or max-height) doesn't work in IE. You need to set a percentage width. Work out roughly what proportion of the screen you want to take up and then no matter what size the screen is, it'll always take up the same proportion. So at a viewport of 800px, 350px would be about 45%, so width="45%". you can do it a more complicaated way by using javascript. You can get the width of the window in javascript, and do a document.wright and an if statement Example: CODE <script language="javascript"> var widthOfScreen = document.body.clientWidth; var tableWidth if(widthOfScreen>34) { tableWidth="34"; }else{ tableWidth="100%"; } document.write("<table width="+tablewidth+">"); </script> Almost all browsers support javascript! oh... one problem, document.body.clientWidth does NOT work with netscape... sorry Any questions? |
|
|
|
Oct 1 2005, 07:29 AM
Post
#7
|
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 1,161 Joined: 9-May 05 From: Brisbane, QLD Member No.: 6,818 |
QUOTE(qwertyiscool @ Oct 1 2005, 03:10 PM) Any questions? Yeah: why would you want to do it a more complicated way when there are easier options? |
|
|
|
Oct 1 2005, 07:51 AM
Post
#8
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 282 Joined: 1-September 05 From: Wanatos Member No.: 11,382 |
QUOTE(Tyssen @ Oct 1 2005, 01:29 AM) So what would be the easier options? I know about max-with and its compatibility issues, but i think that javascript would do fine. Do you know what pecentage of web surfers have blocked js in their browsers? |
|
|
|
Oct 1 2005, 08:28 PM
Post
#9
|
|
|
Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software. ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 975 Joined: 25-September 05 From: The dungeon deep below the foundation of trap17 Member No.: 12,251 |
QUOTE(Tyssen @ Sep 30 2005, 11:29 PM) um because this will work with almsot every browser! |