473,406 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to place vertically centered elements side by side?

Trying my hand at table-less design. Looking for an XHTML 1.0 strict,
CSS2 compliant solution. Here's the result I'm looking for:

Div I: Some header text
DIV II: Some text and a form which should be vertically centered
Div III: Rest of content

DIV II is the one I cannot resolve. It should span the whole page
width, no matter the size of its content. 'Text A' should be aligned
to the left, 'Form B' should be aligned to the right but both should
be vertically aligned in the middle.

Table-less layout advocates, here's your chance to make a convert :)
Any suggestions/pointers appreciated.
+================================================= ===================+
| Div I |
| |
+--------------------------------------------------------------------+
| Div II |
| |
| ..................... |
| ..................... : : |
| : Text A : : Form B : |
| ..................... : : |
| ..................... |
| |
| |
+--------------------------------------------------------------------+
| Div III |
| |
| |
| text text text text text text text text text text text |
| text text text text text text text text text text text |
| text text text text text text text text text text text |
| text text text text text text text text text text text |
| text text text text text text text text text text text |
| text text text text text text text text text text text |
| text text text text text text text text text text text |
| |
| |
+================================================= ===================+
Jul 20 '05 #1
8 5096
Terry wrote:
Looking for an XHTML 1.0 strict,
Don't. Use HTML 4.01 strict unless you have specialized needs that call
for XHTML.
Here's the result I'm looking for:

Div I: Some header text
Default static position for that.
DIV II: Some text and a form which should be vertically centered
This is not trivial. You'd have a fighting chance if IE/Win supported
display: table-cell. Alas, it doesn't. Why do you want this? It looks to
me like you can put a healthy padding-top and padding-bottom, and float
Text A left with it a suitable width (in flexible units, naturally). It
won't be centered vertically in Div II, but it will come close to what
you want.
Div III: Rest of content
Clear the 3rd div, and you're done, I think.
DIV II is the one I cannot resolve.
Yeah, that's the tricky one. Google this group for vertical-align center
and see what has come up about this before. (There'll be *lots* of hits.)
Table-less layout advocates, here's your chance to make a convert :)


You'll forgive me for being blunt, but I don't really feel obligated to
convert you. If you want to learn something about tableless layout,
you've come to the right place. But if you seek conversion, you might
want to look for a www cult. I hear there are certain secret www arts
taught in Redmond, if that's your thing.

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 20 '05 #2
Hi Brian,

Thanks for your suggestions, I'll keep them in mind. Sorry about my
'convert' comment -- it was made more out of frustration than anything
else... Seems like table-less is all the rage and I keep hearing that
this is 'How It Should Be Done' -- but then I come up with a relatively
common scenario and then, all I get are responses telling me 'why do you
need this' and 'sorry no can do, but try this -- it's close!"

I really appreciate the effort to help but I'm getting more and more
convinced that table-less design is best suited for really simple
layouts and that anything fancy will have to be done with tables.
Granted, this has much more to do with sucky browser support than with
CSS itself :(

Thanks,

Original :: Brian :: 2004-08-15 22:24
DIV II: Some text and a form which should be vertically centered


This is not trivial. You'd have a fighting chance if IE/Win supported
display: table-cell. Alas, it doesn't. Why do you want this? It looks to
me like you can put a healthy padding-top and padding-bottom, and float
Text A left with it a suitable width (in flexible units, naturally). It
won't be centered vertically in Div II, but it will come close to what
you want.
Table-less layout advocates, here's your chance to make a convert :)


You'll forgive me for being blunt, but I don't really feel obligated to
convert you. If you want to learn something about tableless layout,
you've come to the right place. But if you seek conversion, you might
want to look for a www cult. I hear there are certain secret www arts
taught in Redmond, if that's your thing.

Jul 20 '05 #3
Hi

I suppose if you were really desperate you could try using frames on
your page. One frame on top, one on the bottom and one in the middle.
The frames on top and bottom would be a set distance while the frame in
the middle would be set to a percentage. At least that's how I remember
doing it once to get a graphic appear at the center of a page.

Having said that I remember one of my teachers last year saying that
framed pages are only really suitable to web sites with a small number
of pages, where bookmarking isn't such an issue. I did actually see one
site that explained how to get around the bookmarking problem with
frames but I can't remember what I did with the link.

Tables do still have a place as long as you don't make them overly
complicated. There is a good tutorial on tables at
http://webmonkey.wired.com/webmonkey...l?tw=authoring

It's an old tutorial but it's still relevant in that it talks about
making tables with less code and thereby reducing download times. After
that you can do a google on css tables.

Have a good day

Peter Mount
in**@petermount.au.com

Terry wrote:
Hi Brian,

Thanks for your suggestions, I'll keep them in mind. Sorry about my
'convert' comment -- it was made more out of frustration than anything
else... Seems like table-less is all the rage and I keep hearing that
this is 'How It Should Be Done' -- but then I come up with a relatively
common scenario and then, all I get are responses telling me 'why do you
need this' and 'sorry no can do, but try this -- it's close!"

I really appreciate the effort to help but I'm getting more and more
convinced that table-less design is best suited for really simple
layouts and that anything fancy will have to be done with tables.
Granted, this has much more to do with sucky browser support than with
CSS itself :(

Thanks,

Original :: Brian :: 2004-08-15 22:24
DIV II: Some text and a form which should be vertically centered

This is not trivial. You'd have a fighting chance if IE/Win supported
display: table-cell. Alas, it doesn't. Why do you want this? It looks to
me like you can put a healthy padding-top and padding-bottom, and float
Text A left with it a suitable width (in flexible units, naturally).
It won't be centered vertically in Div II, but it will come close to
what you want.
Table-less layout advocates, here's your chance to make a convert :)

You'll forgive me for being blunt, but I don't really feel obligated to
convert you. If you want to learn something about tableless layout,
you've come to the right place. But if you seek conversion, you might
want to look for a www cult. I hear there are certain secret www arts
taught in Redmond, if that's your thing.

Jul 20 '05 #4
How am I supposed to post my replies in a newsgroup?:
http://allmyfaqs.com/faq.pl?How_to_post

Terry wrote:
Seems like table-less is all the rage and I keep hearing that this is
'How It Should Be Done'
It has advantages over the old nested table stuff; many of those
advantages are for the *visitor* to the site, and that's important to
keep in mind. Too often authors think only about their design needs,
forgetting the audience in the process.
then I come up with a relatively common scenario
Using old techniques, right? If you want to give this a go, and you have
a bit of time so spend learning, then start with no layout at all.
Create a few documents with navigation and content, using strict markup
(HTML 4.01 strict is probably the right choice). Forget about the
visuals. When you've got a fully functional site, start in on the CSS,
trying different color schemes and layout ideas.

If you try to redo table layouts, you'll be frustrated and disappointed.
and then, all I get are responses telling me 'why do you need this'
and 'sorry no can do, but try this -- it's close!"
That's as much an aknowledgement of the realities of the www as anything
else. The more you try to force your layout, the worse it breaks in
unanticipated situations. The nice thing about CSS is the power it gives
you to offer a rich visual appearance with a high degree of flexibility.
Old methods gave you the visuals, but took away flexibility.
I'm getting more and more convinced that table-less design is best
suited for really simple layouts and that anything fancy will have to
be done with tables.


Have a look here:

http://www.csszengarden.com/

NB: I don't recommend copying their techniques unless you know what
you're doing. Too many of their designs are, in fact, brittle or hostile
to user needs (what's with the small font sizes?). But it should at
least disabuse you of the notion that CSS can't do anything interesting.

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 20 '05 #5
Brian wrote:

It has advantages over the old nested table stuff; many of those
advantages are for the *visitor* to the site, and that's important to
keep in mind. Too often authors think only about their design needs,
forgetting the audience in the process.

What are some of those advantages?

--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Jul 20 '05 #6
jmm-list-gn wrote:
Brian wrote:
It has advantages over the old nested table stuff; many of those
advantages are for the *visitor* to the site


What are some of those advantages?


To speak only about a layout using nested tables v. css:

CSS can be changed by the user with not too much effort, or turned off
completely. Both Opera and Mozilla (via dev toolbar) provide many ways
to alter a document, in small or big ways.

Browsers must often make two passes to show a table; the first to figure
out how much space is needed for different columns and rows, the second
to actually put it in the space. If you use nested tables, it must do
the same thing for each nested table, then continue with the parent
table. Using proper markup with css lets you avoid this. Additionally,
the markup is also leaner. Nested table layouts usually come with spacer
gifs. Using margins and padding means less bytes, and less hits.

That's 2 advantages. Do I need a third? :-)

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 20 '05 #7
Brian wrote:

[...]

That's 2 advantages. Do I need a third? :-)

No, thanks, that'll do. I've been replacing tables with divs on our
site where I can. Now I have even more motivation. :-)

--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Jul 20 '05 #8
Terry wrote:
Trying my hand at table-less design. Looking for an XHTML 1.0 strict,
CSS2 compliant solution. Here's the result I'm looking for: DIV II: Some text and a form which should be vertically centered
Hard to say. URL?
DIV II is the one I cannot resolve. It should span the whole page
width, no matter the size of its content.
Easy, do nothing.
'Text A' should be aligned to the left,
And? That is easy, but you most likely also want to limit it width.
'Form B' should be aligned to the right but both should be vertically aligned in the middle.
Something from:
http://www.student.oulu.fi/~laurirai/www/css/middle/

Not too hard. But now you have only described something that should cause
text A and text B to overlap, and overflow div II. So there lies your
problem, and solution depends much on real case. Easy to solve, if you
pretend that IE supports min-height, I think.
Table-less layout advocates, here's your chance to make a convert :)
Any suggestions/pointers appreciated. +--------------------------------------------------------------------+
| Div II |
| |
| ..................... |
| ..................... : : |
| : Text A : : Form B : |
| ..................... : : |
| ..................... |
| |
| |
+--------------------------------------------------------------------+


What are text A and text B? If they are practically random, this is hard.
(but not impossible, even in IE) If there is some clues, it should not be
too hard.

URL?
--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
I'm looking for work | Etsin työtä
Jul 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Kai Grossjohann | last post by:
I have a table which contains a top-aligned table cell: .... <tr style="height:40"> ... <td colspan="1" rowspan="2" align="left" valign="top" style="overflow:hidden;">...
19
by: George Ziniewicz | last post by:
.. I try to use CSS when possible, though I am still learning and don't maximize its use. In particular, I still use a table to provide for a centered image in a few slideshows (though table...
27
by: FL | last post by:
Hi Everyone, I know howto center a block using margin-left: auto ; margin-right: auto ; but I'm trying to center vertically a box, any idea to solve this?
10
by: john T | last post by:
Is there anyway to vertically center a html table using css in such a way it does not alter the html table. When I tryied it just screws up.
5
by: Wilhelm Kutting | last post by:
Hi i want to use the following layout: ----------------- | | | | Text line 1 | | | Text line 2 | image.jpg | | ... | | | | | |
11
by: Serg | last post by:
I had some CSS problems, and they were solved by someone who pointed out to me that I should have <!DOCTYPE ..... at the top of my code, which I now do. And it fixed all the inheritance...
1
by: StickMaker | last post by:
On my page at http://www.sticksite.com/grizzly/ I want all the images down the left side with the relevant text vertically centered beside each image. NO tables; CSS only. The only way I can get it...
4
by: John | last post by:
Is it possible to center a memo field value vertically? I use a memo field for printing address labels and I would like the addresses to show up centered vertically. Thanks, john
1
by: Maxime | last post by:
Hello, I want to make a button that automatically resizes according to the text length and the font size (which can be changed in firefox pretty easily with the browser). The button already...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.