Max Table Width

Pages: 1, 2
free web hosting

Read Latest Entries..: (Post #13) by iGuest on Mar 19 2008, 08:19 AM. (Line Breaks Removed)
thanks, man Max Table Width Jonny, thanks man. You not only helped me control my table width, you also opened up a new galaxy for me-- css expressions. People named jonny are tops.-reply by johny
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Open Discussion > CONTRIBUTE > Computers > Programming Languages > HTML, XML etc..

Max Table Width

Amezis
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?

Reply

sxyloverboy
CODE
<table width="350"> bla </table>


or you can do it in css. ill explain that too if you want me too.

Reply

Amezis
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?

Reply

arboc7
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!

Reply

Tyssen
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%".

Reply

galexcd
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? huh.gif

 

 

 


Reply

Tyssen
QUOTE(qwertyiscool @ Oct 1 2005, 03:10 PM)
Any questions?  huh.gif

Yeah: why would you want to do it a more complicated way when there are easier options? rolleyes.gif

Reply

Lozbo
QUOTE(Tyssen @ Oct 1 2005, 01:29 AM)
Yeah: why would you want to do it a more complicated way when there are easier options?  rolleyes.gif
*


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?

Reply

galexcd
QUOTE(Tyssen @ Sep 30 2005, 11:29 PM)
Yeah: why would you want to do it a more complicated way when there are easier options?  rolleyes.gif
*



um because this will work with almsot every browser! mad.gif

Reply

Tyssen
QUOTE(qwertyiscool @ Oct 2 2005, 06:28 AM)
um because this will work with almsot every browser! mad.gif
*


Not if they've got js turned off it won't. dry.gif
And if you know what you're doing with CSS, there are work-arounds to get IE to accept min-width & min-height.

Reply

Latest Entries

iGuest
thanks, man
Max Table Width

Jonny, thanks man. You not only helped me control my table width, you also opened up a new galaxy for me-- css expressions.

People named jonny are tops.

-reply by johny

Reply

iGuest
My first time here, and I noticed this question on max-width.
The problem of course is that IE doesn't recognize that property, but there IS a way around it. Unfortunately, the line of code wont validate, but blame IE for that, for not having a decent browser!!

This will apply to a main content table too, so you can go full width, but stop it expanding beyond a certain point. Say 1000px, that way you don't get your line length too long for comfortable reading.

Suppose you want the table to expand to 500px, but no wider?
In your style sheet, put the max-width: 500px; in the correct place. (in the body} section)
Now, you need to define how your table displays with IE
so add in this.

table {
width:expression(document.body.clientWidth > 500? "500px": "auto" );
}


This is for IE....it will work on versions above 4.

What it's saying, is, is the table wider than 500px? If so, make it 500px....anything below will expand to an auto width.
Firefox will ignore this, and IE will ignore the max-width, so you need both of them.

Unfortunately, the ? will stop a clean validation, but thats about the easiest way around the problem. There are other solutions, using ems, but they are more complex.

If only IE would design a compliant browser, these sort of problems wouldn't arise!

Cheers, Jonny.

-Jonny

Reply

Tyssen
QUOTE(qwertyiscool @ Oct 9 2005, 01:54 PM)
how many browsers do you know nowadays that dont have js enabled?
Only weird people dont enable js on their browsers, or they do it to tempararily test something.

It's not browers; it's users and you'd be surprised at the number. It's generally not something that individual users do, but rather IT departments looking after big networks of computers that only want users to have the minimum of functionality.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Pages: 1, 2
Recent Queries:-
  1. ie6 add horizontal scroll table over width - 3.57 hr back. (2)
  2. table cell max width - 4.00 hr back. (1)
  3. set table max width - 7.96 hr back. (1)
  4. table width, auto max - 8.53 hr back. (1)
  5. - 18.71 hr back. (1)
  6. html table maximum line width - 19.79 hr back. (2)
  7. html max size of table - 20.57 hr back. (1)
  8. set max table width 1024 - 25.83 hr back. (1)
  9. table max width - 11.18 hr back. (3)
  10. set comment section to max width how to - 32.37 hr back. (1)
  11. max-width column in table - 35.68 hr back. (2)
  12. php max from table - 35.76 hr back. (1)
  13. max length in table html - 37.13 hr back. (1)
  14. html table firefox ignores max-width - 44.70 hr back. (2)
  15. Similar Topics

    Keywords : max, table, width

    1. Width Of Display Area Of Browser Window
      is there a formula? (6)
    2. Ie Table Width In A Div Tag
      Table expands past screen at 100% (5)
      Hey everyone. I have been designing websites for a long time but i have recently decided to tryout
      the DIV layout technique instead of just using good old tables. However, this is the biggest problem
      i have come across. So I have a page where i need to have a table to display a whole bunch of
      details on armor in a game since the site is for players of final fantasy. However, when i do
      width="100%" so that the table expands the whole way to the side of the div so it looks the best it
      now will go past the edge and off the screen at 100%. Below is most of the code. Please h....
    3. Table Width Help
      table width="100%" goes off screen (2)
      Hey everyone. My problem is that current i have a left menu and a right menu which are created using
      a div the properties listed below. Then i have a center section to my website where i have a table
      that i need to fill the remaining space on the screen (aka the space from the right side of the left
      menu to the left side of the right menu). However, when i set the table's width to 100%, it goes
      of the screen. Can anyone help me with this? If you look at my main page, the news section works but
      only because the text forces the table to its largest size and then wraps.....
    4. Popup Window With Height And Width?
      (9)
      I will try to explain: When clicking on the link, a pop-up window will be opened. I also want to
      have the width=300 and height=160 (just examples /wink.gif' border='0'
      style='vertical-align:middle' alt='wink.gif' /> ) Could someone give me a short code for that?....
    5. Adding Width And Height To Page
      (8)
      how do you add width and height to your page? without adding it to your link you previously
      clicked... I mean, that the width and height should be included in the ORIGINAL page... i hope
      someone can help me with this... thanks in advance! /cool.gif' border='0'
      style='vertical-align:middle' alt='cool.gif' /> btw: i'm not that familiar with
      scripting.......

      1. Looking for max, table, width

    *RANDOM STUFF*





    *SIMILAR VIDEOS*
    Searching Video's for max, table, width

    *MORE FROM TRAP17.COM*
    advertisement



    Max Table Width



     

     

     

     

    ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
    Express your Opinions, Thoughts or Contribute your information that might help someone here.
    Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
    Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
    500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE