PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.info.authoring.CSS > css for centering a 'table' in a layout
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
css for centering a 'table' in a layout

Réponse
 
LinkBack Outils de la discussion
Vieux 11/03/2008, 20h47   #1
lawpoop@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut css for centering a 'table' in a layout

Hello all -

I'm working on a site that has a survey page for users. I'm fairly new
to css, but I want to use it for layout.

In the page, the user has a a set of radio buttons, five of them, to
pick from. What I want is a center-aligned table layout, with the top
row being the titles of each radio button, and the bottom row being
the radio buttons. Each cell would be the same width.

If I were formatting this using html, I would simply use the table
tags. But, I'm trying to do this using pure css. I have a css layout
that properly center-align and evenly space my radio buttons and their
titles in IE 6, but in firefox, they are left-aligned.

All of the css tutorials that I've looked at so far talk about getting
text to flow around an image, or right- and left- aligning various
navigation features. I haven't found a tutorial about center-aligning
html elements, evenly spacing them, etc. Basically I want to emulate
features of the <table> tags.

Now I know some purists bristle at the suggestion that one call
something a 'table' when it's not a table of data. Please keep in mind
that when I say table, I'm talking about the 2-dimensional structure
of the layout, not the abstract concept of a dataset with columns and
rows. Yes, I am misappropriating the table tags.

Thank you!
  Réponse avec citation
Vieux 11/03/2008, 23h58   #2
Bergamot
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: css for centering a 'table' in a layout

lawpoop@gmail.com wrote:
>
> I have a css layout
> that properly center-align and evenly space my radio buttons and their
> titles in IE 6, but in firefox, they are left-aligned.


Post a URL so we can see what you have done. Do not post code.

--
Berg
  Réponse avec citation
Vieux 11/04/2008, 19h42   #3
lawpoop@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: css for centering a 'table' in a layout

On Mar 11, 6:58 pm, Bergamot <berga...@visi.com> wrote:
> Post a URL so we can see what you have done. Do not post code.


Berg, thanks for taking the time to look at this. Here is the URL
( sorry for the delay in response):

http://nerdcraft.net/survey.html

I have the grid of 1-5 questions and radio button answers layed out in
a table. I couldn't find a tutorial for a css grid, so I hacked it for
now. Ideally, I would like to have the question layout in css.

Problems with the progress bar:
In IE, the css progress bar is properly center aligned, but the
progress part is also center aligned within the bar , which is a
problem. The progress part should right left-aligned.

In firefox, the progress area is properly left-aligned, but the whole
bar is left-aligned. I want it to be in the center.
Also, in firefox, the 'add comment' part is broken -- it extends the
content area down past the footer.

I'm thinking the progress bar would also be easier to do as a table,
with fixed pixel widths, instead of css.


  Réponse avec citation
Vieux 12/04/2008, 23h28   #4
Bergamot
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: css for centering a 'table' in a layout

lawpoop@gmail.com wrote:
> On Mar 11, 6:58 pm, Bergamot <berga...@visi.com> wrote:
>> Post a URL so we can see what you have done. Do not post code.

>
> http://nerdcraft.net/survey.html
>
> I have the grid of 1-5 questions and radio button answers layed out in
> a table. I couldn't find a tutorial for a css grid, so I hacked it for
> now. Ideally, I would like to have the question layout in css.


Why? the radio buttons look like tabular data to me. Use a table, except
don't use icky presentational HTML attributes, like align=center. Mixing
HTML and CSS styles will only make a mess, and a real PITA to maintain.
BTW, putting the radio buttons in a table doesn't mean the whole page
needs to be in a table.

And use a better doctype. The one in that test page triggers quirks
mode, which will not give consistent results across browsers as you've
already discovered. Use HTML 4.01 strict if you want the best compatibility.

> In firefox, the progress area is properly left-aligned, but the whole
> bar is left-aligned. I want it to be in the center.


Drop the align=center on that cell - that is for aligning text within
the block, not for aligning blocks themselves. Look up margin:auto

--
Berg
  Réponse avec citation
Vieux 13/04/2008, 04h51   #5
lawpoop@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: css for centering a 'table' in a layout

On Apr 12, 6:28 pm, Bergamot <berga...@visi.com> wrote:

> Why? the radio buttons look like tabular data to me. Use a table, except
> don't use icky presentational HTML attributes, like align=center. Mixing
> HTML and CSS styles will only make a mess, and a real PITA to maintain.
> BTW, putting the radio buttons in a table doesn't mean the whole page
> needs to be in a table.


So what exactly is the complaint people make about using table tags
for 'tabular data'? This certainly isn't a train schedule or a chart
in table format.
When they say 'tabular data', do they mean simply 'grid'?

Do the labels for the radio buttons also belong in the table? I'd
assume so; I can't imagine how you get them to line up with their
radio buttons without it.

> And use a better doctype. The one in that test page triggers quirks
> mode, which will not give consistent results across browsers as you've
> already discovered. Use HTML 4.01 strict if you want the best compatibility.
>
> > In firefox, the progress area is properly left-aligned, but the whole
> > bar is left-aligned. I want it to be in the center.

>
> Drop the align=center on that cell - that is for aligning text within
> the block, not for aligning blocks themselves. Look up margin:auto


Awesome! Thanks, Berg!
  Réponse avec citation
Vieux 13/04/2008, 05h09   #6
lawpoop@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: css for centering a 'table' in a layout

Or, let me ask a more general question: Is an html table an
appropriate way to align any set of elements of an HTML page that are
to be in a grid layout?

Or is there a pure css way to do a grid-style layout? Something where
you wanted, say, two rows and four columns of some elements, that all
have the same width and spacing distribution?
  Réponse avec citation
Vieux 13/04/2008, 10h06   #7
Ben C
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: css for centering a 'table' in a layout

On 2008-04-13, lawpoop@gmail.com <lawpoop@gmail.com> wrote:
> Or, let me ask a more general question: Is an html table an
> appropriate way to align any set of elements of an HTML page that are
> to be in a grid layout?


Supposedly not. You're only meant to use an HTML table if there's
something abstractly tabular about the data independently of how it
might be displayed.

"Abstractly tabular" is a contrived idea since really a table is a kind
of presentation.

Perhaps a better criterion is whether the table layout is part of the
meaning of the data.

> Or is there a pure css way to do a grid-style layout? Something where
> you wanted, say, two rows and four columns of some elements, that all
> have the same width and spacing distribution?


Yes, you just put display: table, display: table-row, display:
table-cell etc. on the elements you want to be tables, rows and cells.
It should all work exactly the same (but with the added feature that you
can leave out bits of the structure and have it filled in for you in a
defined way). It doesn't work in IE.
  Réponse avec citation
Vieux 13/04/2008, 18h30   #8
Bergamot
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: css for centering a 'table' in a layout

lawpoop@gmail.com wrote:
> Or, let me ask a more general question: Is an html table an
> appropriate way to align any set of elements of an HTML page that are
> to be in a grid layout?


It depends on what you mean by "grid". A data grid has relationships
between rows and columns, and is tabular. If you're thinking of the
general design principle of grid layouts, that's not tabular. In your
case there was a direct relationship between the radio button and its
corresponding label, as well as the buttons as a group. Granted, it
could have been laid out various ways, but a table is not wrong for
this, IMO.

> Or is there a pure css way to do a grid-style layout? Something where
> you wanted, say, two rows and four columns of some elements, that all
> have the same width and spacing distribution?


There are plenty of CSS templates with varying numbers of columns.

--
Berg
  Réponse avec citation
Vieux 14/04/2008, 08h33   #9
Ben C
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: css for centering a 'table' in a layout

On 2008-04-14, dorayme <doraymeRidThis@optusnet.com.au> wrote:
> In article <slrng03j9s.bm8.spamspam@bowser.marioworld>,
> Ben C <spamspam@spam.eggs> wrote:
>

[...]
>> Perhaps a better criterion is whether the table layout is part of the
>> meaning of the data.

[...]
> Perhaps it could be usefully said that an html table starts to be
> particularly appropriate where the table itself provides information to
> the user. How is this possible? By common knowledge and education, most
> people know that a table is being presented (clues like borders to
> delineate rows and columns, headings and so on all ) and this
> knowledge immediately alerts the user that there is a correct way to
> read the layout. Read it one way and you get true things, read it
> another way and you get false things. There is order and structure. It
> is a particularly meaningful thing.


That's what I was trying to say above, although you have put it better.
  Réponse avec citation
Vieux 14/04/2008, 12h19   #10
Andy Dingley
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: css for centering a 'table' in a layout

On 13 Apr, 05:09, lawp...@gmail.com wrote:
> Or, let me ask a more general question: Is an html table an
> appropriate way to align any set of elements of an HTML page that are
> to be in a grid layout?


Yes!

> Or is there a pure css way to do a grid-style layout?


No.

To get "grid like" behaviour (the grid relations between cells take
precedence over other size or positioning constraints applied to
cells) you must apply the CSS "table-*" property values and behaviours
to the CSS display property. You can do this most easily by using the
default CSS properties for <table>.

You may also do this by applying these same CSS values to a <div> (or
any suitable element) through a stylesheet. However this isn't
recommended - it's not supported by all browsers, and as it was
originally added to the CSS specification as a means of working with
CSS + XML rather than HTML, there's no pressing need why its support
should ever be extended for HTML in general.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h33.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,21008 seconds with 18 queries