473,396 Members | 1,726 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,396 software developers and data experts.

vertical alignement of character in text

I have a group of links prefixed with the arrow as follows:
»link1 »link2 »link3

I would like the arrows to be vertically aligned middle of the text, like
as if they were bullets of list item, but without linebreaks.

The text would be quite large and set to a percentage, eg. 200%, so
there's no way of knowing the exact pixel height.

If all items were simply placed after each other, the arrow would naturally
fall to the baseline of the text.

Using an old table, the align middle effect could be done as follows:
<table><tr>
<td> » </td><td> link1</td
<td> » </td><td> link2 </td>
<td> » </td><td> link3 </td>
</tr></table>

But a table isn't very flexible, as linebreaks do not occur if the window
is scaled down to less than the combined width of all links.

What CSS way(s) are there which can do this better?
Jul 20 '05 #1
11 2551
michael <no****@example.com> wrote:
I have a group of links prefixed with the arrow as follows:
»link1 »link2 »link3
The character » is not an arrow but a quotation markup. Common as it
might be to use it as an arrow symbol, I would recommend using either a
real arrow character or an image. On the other hand, arrows have the
connotation of _direction_, so is this really a "breadcrumb" as it would
suggest to many people?
I would like the arrows to be vertically aligned middle of the text,
like as if they were bullets of list item, but without linebreaks.


Assuming that the links are in a block element with no other content,
i.e. something like

<div class="nav">
»<a href="...">link1</a>
»<a href="...">link2</a>
»<a href="...">link3</a>
...
</div>

then you could use a little trick like

..nav a { vertical-align: -0.2ex; }

which lowers the links so that the quotation marks appear as if (roughly)
middle aligned with them.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Jul 20 '05 #2
michael wrote:
I have a group of links prefixed with the arrow as follows:
»link1 »link2 »link3

I suggest using an image; you have a lot more control over the
appearance and positioning.
The quote marks shown above may not sit on the baseline in all fonts.
So adjusting the text to match may work for your system but not others.

--
jmm dash list at sohnen-moe dot com
(Remove .TRSPAMTR for email)
Jul 20 '05 #3
On 17 Jun 2004 23:16:54 GMT, James Moe <jm***************@sohnen-moe.com>
wrote:
michael wrote:
I have a group of links prefixed with the arrow as follows:
»link1 »link2 »link3

I suggest using an image; you have a lot more control over the
appearance and positioning.
The quote marks shown above may not sit on the baseline in all fonts.
So adjusting the text to match may work for your system but not others.


In what way would you suggest using an image improves the chances of a
more suitable positioning, seeing that some browsers don't resize images
with the text?

Using a chracter re-positioned relative to the font size is going to give
a better appearance IMO.
Jul 20 '05 #4
Neal wrote:
Using a chracter re-positioned relative to the font size is going to give
a better appearance IMO.


I agree it would be better to use a text character for resizin purposes,
whilst I guess an image could simply be align=middle, how exactly could I
re-position the » character relative to the font size?

Jul 20 '05 #5
On Fri, 18 Jun 2004 16:11:48 +0200, michael <no****@example.com> wrote:
Neal wrote:
Using a chracter re-positioned relative to the font size is going to
give
a better appearance IMO.


I agree it would be better to use a text character for resizin purposes,
whilst I guess an image could simply be align=middle, how exactly could I
re-position the » character relative to the font size?


Like Jukka said, using a font-size-based measurement like ex or em. You
did see Jukka's response? I quote it below.

"Assuming that the links are in a block element with no other content,
i.e. something like

<div class="nav">
»<a href="...">link1</a>
»<a href="...">link2</a>
»<a href="...">link3</a>
...
</div>

then you could use a little trick like

..nav a { vertical-align: -0.2ex; }

which lowers the links so that the quotation marks appear as if (roughly)
middle aligned with them."
Jul 20 '05 #6
> Like Jukka said, using a font-size-based measurement like ex or em. You
did see Jukka's response? I quote it below.


Yes I read it, but I also read somewhere that ex is badly approximated by
browsers, but maybe that's old information. I'll test. Thanks for the info.

Jul 20 '05 #7
michael <no****@example.com> wrote:
- - I also read somewhere that ex is badly approximated by
browsers, but maybe that's old information


It is still true in the sense that browsers generally do not implement ex
as it should be implemented, as the font's x height value. Instead they
treat as 0.5em. But although this is incorrect - the x height varies by
font, so that for serif fonts, ex is usually smaller than 0.5em, for
sans-serif fonts it is usually larger than 0.5em - it gives reasonable
results in cases like this.

In effect, one can use ex when it is acceptable that browsers implement
it as 0.5em and desirable that they implement it correctly as the
x height.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Jul 20 '05 #8
Neal wrote:

I suggest using an image; you have a lot more control over the
appearance and positioning.


In what way would you suggest using an image improves the chances of a
more suitable positioning, seeing that some browsers don't resize images
with the text?

The image would not necessarily re-size, of course, but would at least
be positioned in the middle as desired. Using the text arrow assumes the
user's font will actually display what the OP thinks will be displayed.

--
jmm dash list at sohnen-moe dot com
(Remove .TRSPAMTR for email)
Jul 20 '05 #9
On Fri, 18 Jun 2004 21:34:53 +0000 (UTC), Jukka K. Korpela
<jk******@cs.tut.fi> wrote:
michael <no****@example.com> wrote:
- - I also read somewhere that ex is badly approximated by
browsers, but maybe that's old information


It is still true in the sense that browsers generally do not implement ex
as it should be implemented, as the font's x height value. Instead they
treat as 0.5em. But although this is incorrect - the x height varies by
font, so that for serif fonts, ex is usually smaller than 0.5em, for
sans-serif fonts it is usually larger than 0.5em - it gives reasonable
results in cases like this.

In effect, one can use ex when it is acceptable that browsers implement
it as 0.5em and desirable that they implement it correctly as the
x height.

Question: if -0.2ex might be rendered differently, wouldn't -0.1em yield
more predictable results, and therefore be more desirable? Especially when
the actual pixel height of 1em would be under 20px, the actual center of
the ex-height wouldn't vary more than a pixel... or am I missing
something? And what is it? ;)
Jul 20 '05 #10
Neal <ne*****@yahoo.com> wrote:
Question: if -0.2ex might be rendered differently, wouldn't -0.1em
yield more predictable results, and therefore be more desirable?
More predictable, yes; but not necessarily more desirable, if -0.2ex
describes better what you really want.
Especially when the actual pixel height of 1em would be under 20px,
the actual center of the ex-height wouldn't vary more than a pixel...


In this particular case, dealing with a specific character (which IMHO
should not be used instead, since it is a punctuation mark [sorry for my
typo "markup" in my original reply]), it seemed, after some quick tests,
that -0.2ex might be close to the desired appearance. I tend to think
such things in terms of the x height, and therefore used the ex unit. In
this case it would indeed rarely matter whether one uses -0.2ex or
-0.1em. But I think that typical when you set the vertical-align property
for a piece of text (e.g., for <sub> or <sup> elements to get a more
consistent appearance), ex better relate to the goal. For example, to set
some character in a suitable superscript position, I would rather
describe "suitable" in terms of the x height than the font height.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Jul 20 '05 #11
> In effect, one can use ex when it is acceptable that browsers implement
it as 0.5em and desirable that they implement it correctly as the
x height.


I tested this, across browsers and the result is fine. Thanks for the info!

Jul 20 '05 #12

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

Similar topics

1
by: Kenneth | last post by:
Okay, I've been scouring Google for hours looking for a solution to this problem, but as of yet I can't find one. XHTML Transitional seems to specify that I can no longer set a table's height to...
1
by: Joop | last post by:
Does anybody know a way to print a vertical text field spread over more detail lines? regards Joop
4
by: Greenhorn | last post by:
Hi, Can i know how formfeed exactly works, also vertical tab, i have used vertical tab with printf() as shown below: printf("This is the \v line"); the output: This is the ♂ line
0
by: DraguVaso | last post by:
Hi, I'm having a DataGrid on which I want to draw 2 moveable vertical lines. What should happen is: When I move a vertical line, I have somewhere an indication on which character in the datagrid...
2
by: harvie wang | last post by:
Hi, I want to show vertical text in textbox, how to do? Best Wish, Harvie 2006-7-16
5
by: Markus Ernst | last post by:
Hello This is a test example: http://www.markusernst.ch/anthracite/ http://www.markusernst.ch/anthracite/living_divani.html After googling and experimenting for several hours, I ended up...
3
by: acunnon | last post by:
I am trying to put together an login page my problem is getting the three items aligned to the middle verticaly without specifing a height to anything on the page. CSS html{ height:100%;...
3
by: Spiros Bousbouras | last post by:
The fact that vertical tab and form feed exist both in the basic source character set and the basic execution character set suggests to me that there is a class of display devices where vertical...
8
by: ayamopamo | last post by:
Hi- I am trying to center a web page. It seems like this should be very simple to do, but apparently it isn't my day. I have successfully centered the background by calling it in the css body tag:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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.