473,666 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5106
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
8451
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;"> ...contents.explained.later... </td> ...
19
5732
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 vertical align doesn't work in Mozilla): http://zintel.com/homepics.html I've used combinations of <center>, style align 'center', table cell align, valign and height='100%' to get what I want, but I wonder if CSS can do it by itself.
27
9242
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
26869
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
1859
by: Wilhelm Kutting | last post by:
Hi i want to use the following layout: ----------------- | | | | Text line 1 | | | Text line 2 | image.jpg | | ... | | | | | |
11
3061
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 problems, but it caused my ability to center Tables vertically to disappear. If I remove that top line, all is good. Except for my previous inheritance problems. The thing is my code calls one funtion with the parameter $out_msg which is always in...
1
2271
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 now is to use a lot of BR html tags to add space under each text so that the next image and text are not "all over the page." Can anyone tell this css-beginner how to fix the page, please?
4
3763
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
5633
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 works for resizing horizontally, the problem is when I enlarge the text using firefox, the text doesnt stay aligned with the button. If the text is larger, the text is not centered vertically in the button.
0
8454
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8878
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8644
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6200
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5671
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4200
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1778
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.