Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Center Text Vertically
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mike Copeland  
View profile  
 More options Jan 12, 6:13 pm
Newsgroups: comp.infosystems.www.authoring.stylesheets
From: mrc2...@cox.net (Mike Copeland)
Date: Thu, 12 Jan 2012 16:13:41 -0700
Local: Thurs, Jan 12 2012 6:13 pm
Subject: Center Text Vertically
   I'm working with some code I got here, but I'm stumped on one issue:
I want to align the text (e.g. "Home", Timing Services", etc.) centered
vertically in the buttons.  I've looked at and tried various CSS options
that would seem to do what I want, but nothing does so.  8<{{
   Please advise.  TIA

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>Use CSS</title>
<style type="text/css">
        .nav a span { font-size: .8em; }
        .floating li { float: left; }

        .inlineblock li
        {
                display: inline-block;
                vertical-align: bottom;
        }

        .nav li
        {
                margin-bottom: .1em;
                margin-right: 800px;
                margin-left: 1px;              
                text-align: center;
                list-style-type: none;
                line-height: 3em; */
        }

        .nav a:link, .nav a:visited
        {
                color: #fff;
                background: #1c508c;
                text-decoration: none;
                height: 3em;
                display: block;
                border: 3px outset #1c508c;
                padding: .2em;
        }

        .nav a:hover, .nav a:focus
        {
                border-width: 2px 4px 4px 2px;
                color: #ff0;
                background: #7c9ec4;
        }

        .nav a:active
        {
                border-width: 4px 2px 2px 4px;
                border-style: inset;
                color: #f00;
                background: #3c4e64;
        }
</style>
</head>
<body>
<p>Using inline-block list items:</p>
<div class="inlineblock">
  <ul class="nav">
    <li><a href=".nav">Home</a></li>
    <li><a href=".nav">Race Results<br>
    <span>(presented by Runners Den)</span></a></li>
    <li><a href=".nav">Event Calendar/<br>Online Registration</a></li>
    <li><a href=".nav">Results, Questions,<br>Problems</a></li>
    <li><a href=".nav">Timing Services</a></li>
    <li><a href=".nav">About Us</a></li>
    <li><a href=".nav">Contact Us</a></li>
  </ul>
</div>
</body>
</html>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
dorayme  
View profile  
 More options Jan 12, 7:27 pm
Newsgroups: comp.infosystems.www.authoring.stylesheets
From: dorayme <dora...@optusnet.com.au>
Date: Fri, 13 Jan 2012 11:27:29 +1100
Local: Thurs, Jan 12 2012 7:27 pm
Subject: Re: Center Text Vertically
In article
<MPG.2979170eccbffed7989...@news.eternal-september.org>,
 mrc2...@cox.net (Mike Copeland) wrote:

>    I'm working with some code I got here, but I'm stumped on one issue:
> I want to align the text (e.g. "Home", Timing Services", etc.) centered
> vertically in the buttons.  I've looked at and tried various CSS options
> that would seem to do what I want, but nothing does so.  8<{{
>    Please advise.  TIA

...

Your markup made it look centred in the browsers I looked at it
on. Are you sure you want the buttons to go down the page (as
they do) instead of across (which is the main point really of
inline-block). Why not post a URL to at least have it appear as  
close to how you want it as you can get.

Your css is a little puzzling, margin-right of 800px; surely just
added to test something or other? Some things like the float
doing nothing much, your line-height of even 3em making some text
disappear from your buttons. I did not see a start comment but an
end comment in your CSS? URLs are best, then we see what you want
us to see.

If the text in the buttons is of different number of lines,
button to button, then there are HTML table ways to align the
text to the middle and there are CSS display: table; ways.

For a wild example:

   ul
   {
      display: table;
      margin: 0;
      padding: 0;
   }

   li
   {
      margin-right: .2em;
      margin-bottom: 1em;
      float: left;
      text-align: center;
      list-style-type: none;
   }

   a
   {
      display: table-cell;
      vertical-align: middle;
      color: #fff;
      background: #1c508c;
      text-decoration: none;
      height: 5em;
      border: 3px outset #1c508c;
      padding: .2em;
   }

<ul>
    <li><a href=".nav">Home</a></li>
    <li><a href=".nav">Race Results<br>
    <span>(presented by Runners Den)</span></a></li>
    <li><a href=".nav">Event Calendar/<br>Online
Registration</a></li>
    <li><a href=".nav">Results, Questions,<br>Problems</a></li>
    <li><a href=".nav">Timing Services</a></li>
    <li><a href=".nav">About Us</a></li>
    <li><a href=".nav">Contact Us</a></li>
  </ul>

--
dorayme


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mike Copeland  
View profile  
 More options Jan 12, 10:26 pm
Newsgroups: comp.infosystems.www.authoring.stylesheets
From: mrc2...@cox.net (Mike Copeland)
Date: Thu, 12 Jan 2012 20:26:59 -0700
Local: Thurs, Jan 12 2012 10:26 pm
Subject: Re: Center Text Vertically
In article <dorayme-2E581D.11272913012...@news.albasani.net>,
dora...@optusnet.com.au says...

   I'm trying to modify the following URL:
        www.raceplaceevents.com
and although I have that working (more or less) I was investigating
other ways to do such things.  I'd like to tweak the look of the buttons
(such as rounded corners) and liked what I saw in the code on which I
based my query.

> If the text in the buttons is of different number of lines,
> button to button, then there are HTML table ways to align the
> text to the middle and there are CSS display: table; ways.

   Your sample code didn't work, because the buttons weren't of the same
size, as well as changing size and shape when any one of them was
cursored over.  

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
dorayme  
View profile  
 More options Jan 12, 11:30 pm
Newsgroups: comp.infosystems.www.authoring.stylesheets
From: dorayme <dora...@optusnet.com.au>
Date: Fri, 13 Jan 2012 15:30:59 +1100
Local: Thurs, Jan 12 2012 11:30 pm
Subject: Re: Center Text Vertically
In article
<MPG.297952712f42d6e4989...@news.eternal-september.org>,
 mrc2...@cox.net (Mike Copeland) wrote:

> In article <dorayme-2E581D.11272913012...@news.albasani.net>,
> dora...@optusnet.com.au says...
...
>    Your sample code didn't work, because the buttons weren't of the same
> size, as well as changing size and shape when any one of them was
> cursored over.  

My example markup does not work on say Firefox? Surely?

<http://dorayme.netweaver.com.au/alignSomeText.html>

It works in Sydney. But then, it is lovely weather here at last.

It even works in IE8.

But you cannot count on IE6 or 7 or 8 or maybe even 9 in
"compatibility" mode. But then, you have to be pretty careful
with all sorts of things with earlier IE, even inline-box if you
use it.

--
dorayme


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mike Copeland  
View profile  
 More options Jan 13, 12:35 am
Newsgroups: comp.infosystems.www.authoring.stylesheets
From: mrc2...@cox.net (Mike Copeland)
Date: Thu, 12 Jan 2012 22:35:06 -0700
Local: Fri, Jan 13 2012 12:35 am
Subject: Re: Center Text Vertically
In article <dorayme-24EF4E.15305913012...@news.albasani.net>,
dora...@optusnet.com.au says...

   Well, using the link works nicely (in SeaMonkey, my default browser -
I use others during development after rendering in SeaMonkey).  However,
the buttons line up across the top, and I'd really like to have them
line up vertically on the left (as www.Raceplaceevents.com does), along
with equal fixed widths.  Is there a way to do that?
   (The weather's quite nice here in Phoenix, Arizona, too!)  8<}}

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
dorayme  
View profile  
 More options Jan 13, 1:23 am
Newsgroups: comp.infosystems.www.authoring.stylesheets
From: dorayme <dora...@optusnet.com.au>
Date: Fri, 13 Jan 2012 17:23:14 +1100
Local: Fri, Jan 13 2012 1:23 am
Subject: Re: Center Text Vertically
In article
<MPG.297970786c94a433989...@news.eternal-september.org>,
 mrc2...@cox.net (Mike Copeland) wrote:

...

Yes, certainly.  One quick way is to adapt the CSS in my URL
above. Let's see...

First, obviously, we have to remove the float on li so the list
items stop floating and revert to their natural behaviour of one
under the other. While we are at it, let's remove all the CSS for
the UL element. And lessen the gap between the list items. And
now no need for a right margin.

So far then, we start the new with

<style type="text/css">

li {
margin-right:
margin-bottom: .3em;
/* float: left; remove this line*/
text-align: center;
list-style-type: none;

}

...

Now note that the 'buttons' are only as wide as they need to be
because table cells, like a few other display modes cause
shrink-to-fit. We need to be rid of this as you want all your
buttons to be neatly same width. One simple solution is to add a
set width to the style of the anchor element. So:

a {
display: table-cell;
vertical-align: middle;
color: #fff;
background: #1c508c;
text-decoration: none;
width: 10em; /* add this */
height: 5em;
border: 3px outset #1c508c;
padding: .2em;

}  

And Bob is sort of your uncle.

Mind you, if I was your uncle, I would tell you to remove the
height too now and allow the buttons to be as high as they need
to be and no more.

In fact, if I was *really* your uncle, I would suggest even
simpler and not have the table-cell display. Just:

li
   {
      margin-right: .2em;
      margin-bottom: .3em;
      text-align: center;
      list-style-type: none;
   }

   a
   {
      display: block;      
      color: #fff;
      background: #1c508c;
      text-decoration: none;
      width: 10em;    
      border: 3px outset #1c508c;
      padding: .2em;
   }

   a:hover {color: #c00; background: #ccc;}

and a bit more to cover the states of the anchor...

--
dorayme


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas 'PointedEars' Lahn  
View profile  
 More options Jan 13, 4:52 pm
Newsgroups: comp.infosystems.www.authoring.stylesheets
Followup-To: comp.infosystems.www.authoring.stylesheets
From: Thomas 'PointedEars' Lahn <PointedE...@web.de>
Date: Fri, 13 Jan 2012 22:52:10 +0100
Local: Fri, Jan 13 2012 4:52 pm
Subject: Re: Center Text Vertically

Mike Copeland wrote:
>    I'm working with some code I got here, but I'm stumped on one issue:
> I want to align the text (e.g. "Home", Timing Services", etc.) centered
> vertically in the buttons.  I've looked at and tried various CSS options
> that would seem to do what I want, but nothing does so.  8<{{
> […]
> .nav li
> {
> margin-bottom: .1em;
> margin-right: 800px;

Please don't.

>                 margin-left: 1px;
> text-align: center;
> list-style-type: none;
> line-height: 3em; */

                    ^^
There is a syntax error.  Once that is fixed, declare the line-height of the
`a' element (which text-in-a-line you want to be vertically centered), not
(only) the `li' element.  Of course, this only applies to a *line* of text,
and cannot work as intended if the text is automatically or manually
wrapped.  You are currently doing the latter.

> }

> .nav a:link, .nav a:visited
> {
> color: #fff;
> background: #1c508c;
> text-decoration: none;
> height: 3em;
  ^^^^^^^^^^^^
> display: block;
> border: 3px outset #1c508c;
> padding: .2em;

  ^^^^^^^^^^^^^^
You do not want to do that on the same element due to differences in box
models: In the W3C box model the `a' element will have a CSS 2.1 computed
height of 3.2em; in the MSHTML box model it will be 3em high instead.

I suggest you start your stylesheet from scratch, testing each step in all
of the target environments.

> }

PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
  -- Richard Cornford, cljs, <f806at$ail$1$8300d...@news.demon.co.uk>

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »