Jump to content


Photo

Multiple tags & Table Width


  • Please log in to reply
6 replies to this topic

#1 EriRyoutan

EriRyoutan
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 08 April 2006 - 01:14 AM

First off, Hi!!

Okay, now that that's over with...


First thing I was asking: multiple tags.

Is there a way to do something like...

.something td{stuff} th{stuff}

cause every time I try it ends up making the th stuff default, or it dosen't recognize it...


Secondly...

I want to make a table width automatic, but not over 100% (I don't want a scroll bar on the bottom) ...

... Heeelp? Please?

#2 moberemk

moberemk
  • Members
  • PipPipPip
  • Advanced Member
  • 695 posts

Posted 08 April 2006 - 02:19 AM

For the first one, just do this:
.something td {}
.something th{}
Disclaimer: No matter how harsh I may be, I'm always IMO only.

#3 Vorotaev

Vorotaev
  • Members
  • PipPip
  • Member
  • 27 posts
  • LocationCanada

Posted 08 April 2006 - 12:53 PM

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]For the first one, just do this:
.something td {}
.something th{}[/quote]
Doing that could produce a lot of redundant CSS, especially if a lot of elements are being combined, or there are a lot of properties required for each.

[!--quoteo(post=362703:date=Apr 7 2006, 09:44 PM:name=EriRyoutan)--][div class=\'quotetop\']QUOTE(EriRyoutan @ Apr 7 2006, 09:44 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]First off, Hi!!

Okay, now that that's over with...
First thing I was asking: multiple tags.

Is there a way to do something like...

.something td{stuff} th{stuff}

cause every time I try it ends up making the th stuff default, or it dosen't recognize it...
Secondly...

I want to make a table width automatic, but not over 100% (I don't want a scroll bar on the bottom) ...

... Heeelp? Please?
[/quote]
Are you sure that's what you want to do?

.something will apply the style to anything that has the CLASS "something", regardless of the element.

td{stuff} will apply the style to any TD tag.
th{stuff} will apply the style to any TH tag.

But you've neglected to specify what style should be used for the "something" CLASS. Might you instead want to do this:

<style type="text/css">
.something,td,th{stuff}
</style>
...which would apply the style to any TD or TH tag, as well as any element with a "something" CLASS?

Table width is automatically adjusted to the width of the largest element inside it. There is a CSS2 property called MAX-WIDTH, but Internet Explorer does not support it -- even Internet Explorer 7.0, which is only available to Windows XP users.

[a href=\"http://www.svendtofte.com/code/max_width_in_ie/\" target=\"_blank\"]Here[/a]'s a site which has a trick using Javascript to force IE to adopt a MAX-WIDTH type of thing, but not everyone has Javascript enabled, so I wouldn't rely on it too heavily.

#4 moberemk

moberemk
  • Members
  • PipPipPip
  • Advanced Member
  • 695 posts

Posted 08 April 2006 - 02:05 PM

That's not right. That selector would say "apply the same thing to the something class, the td tag, and the th tag." That wouldn't work, would it?
Disclaimer: No matter how harsh I may be, I'm always IMO only.

#5 EriRyoutan

EriRyoutan
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 08 April 2006 - 02:13 PM

... okay, just to make things easier... (?) Is there somewhere that gives good help on selectors? I've looked around, and they only give the basics, or just kind of... expect you to know it. ><;

I think
.st td,.st th{stuff}
worked... might be wrong, tho... I'll go check...


and as for the table, I know it automatically updates to the widest element, but the problem is that I've got a page that dynamically updates its pictures (all of which have different widths) (go PHP!)

I want to leave it so that it automatically resizes, but without the chance of the scrollbar at the bottom if they're using lower resolutions...

other options would be appreciated. -smiles-

#6 Vorotaev

Vorotaev
  • Members
  • PipPip
  • Member
  • 27 posts
  • LocationCanada

Posted 08 April 2006 - 03:10 PM

[!--quoteo(post=362805:date=Apr 8 2006, 10:35 AM:name=moberemk)--][div class=\'quotetop\']QUOTE(moberemk @ Apr 8 2006, 10:35 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
That's not right. That selector would say "apply the same thing to the something class, the td tag, and the th tag." That wouldn't work, would it?
[/quote]
My understanding is that was what was desired... to have all three (TD, TH, and anything with the "something" CLASS) share the same attributes. Hence why they were all listed together on the same line. I may be mistaken.

If you desire only TD and TH tags with the CLASS of "something" to share properties, you could use:

TD[class=something], TH[class=something] { stuff }

[!--quoteo(post=362806:date=Apr 8 2006, 10:43 AM:name=EriRyoutan)--][div class=\'quotetop\']QUOTE(EriRyoutan @ Apr 8 2006, 10:43 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
... okay, just to make things easier... (?) Is there somewhere that gives good help on selectors? I've looked around, and they only give the basics, or just kind of... expect you to know it. ><;

I think
.st td,.st th{stuff}
worked... might be wrong, tho... I'll go check...
and as for the table, I know it automatically updates to the widest element, but the problem is that I've got a page that dynamically updates its pictures (all of which have different widths) (go PHP!)

I want to leave it so that it automatically resizes, but without the chance of the scrollbar at the bottom if they're using lower resolutions...

other options would be appreciated. -smiles-
[/quote]
I like [a href=\"http://www.w3.org/TR/REC-CSS2/selector.html\" target=\"_blank\"]the W3C page[/a], but it's rather technical. You could try [a href=\"http://css.maxdesign.com.au/selectutorial/\" target=\"_blank\"]this tutorial[/a].

As mentioned, the only way I know of to prevent the page from scrolling while having the table snap to the width of the content is MAX-WIDTH. MAX-WIDTH will not allow the table to expand past the given size constraint, but the table will resize itself automatically up until that point. Internet Explorer doesn't support MAX-WIDTH though, so it may be moot.

#7 EriRyoutan

EriRyoutan
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 09 April 2006 - 03:07 AM

Woo. -dances around a bit- Thanks for everything. I may or may not be back asking more annoying questions later...

-offers cookies to anyone who wants them-




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users