The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Table elements: max-width
Brian Chandler
post Nov 21 2021, 02:42 PM
Post #1


Jocular coder
********

Group: Members
Posts: 2,418
Joined: 31-August 06
Member No.: 43



On my 'about cookies' page: https://imaginatorium.com/cookies.html ... I want to set a maximum width for the "value" column. This contains a basket, which might be long (to see this you need to go to a random page and click lots of 'Add to basket' links), and if this is really long the table ends up the full width of the browser, whereas I would prefer to wrap the cookie values.

I tried setting th style='max-width: 20em' but this had no effect. (I found stackoverflow answers suggesting this.)

So I have set 'width: 20em', but this fixes the width. I seem to remember getting stuck on this a month or so ago, and believed that the point was that for tables "width" really means "min-width', because tables stretch to contain their content. But actually, setting width "works", and the text just flows within it.

In the end I found the w3 thing: https://www.w3.org/Style/css2-updates/css2/...#min-max-widths

This appears to claim that setting max-width sets the maximum width. Well I wish I could see how to do that...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Nov 22 2021, 12:56 PM
Post #2


.
********

Group: WDG Moderators
Posts: 8,934
Joined: 10-August 06
Member No.: 7



That seems to happen in my Firefox. When the TH width is disabled, the cookie values try to expand the table, but not wider than the parent DIV.main. It does seem Firefox obeys max-width on the TABLE element itself.

In my Vivaldi, the column width changes despite the fixed TH width, and the cookie values still wrap into new lines.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Nov 26 2021, 03:15 AM
Post #3


Jocular coder
********

Group: Members
Posts: 2,418
Joined: 31-August 06
Member No.: 43



Thanks for looking at this Christian. So it doesn't work. Well.

I can just use a fixed width, or I suppose since I want it to expand to the width of about 3 items in the "basket" cookie, I can just replace the first two spaces with nbsp...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 29th November 2021 - 01:54 AM