Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Is It Possible To Align Text To The Center And Justify It?, Example inside!
Dagoth Nereviar
post Mar 5 2007, 12:11 AM
Post #1


Privileged Member
*********

Group: [HOSTED]
Posts: 537
Joined: 19-May 06
From: Leeds, UK
Member No.: 23,963



Basically, I have a list (like shown below) but as you can see, some parts stick out more than others, and it doesn't look ordered.

What I wish to know is if it's possible to justify the text so it's ordered, but also keep it in the centre, using CSS tongue.gif Although if another coding language needs to be used, then that's ok smile.gif

Example:
Beginning with A
Beginning with O
Beginning with V
Beginning with W
Beginning with I
Beginning with M
Beginning with P


(Random letters to show how I mean easier tongue.gif without going through the whole alphabet)

Thanks to any who reply biggrin.gif

This post has been edited by Dagoth Nereviar: Mar 5 2007, 12:12 AM
Go to the top of the page
 
+Quote Post
BuffaloHELP
post Mar 5 2007, 01:02 AM
Post #2


Desperately seeking "any key" to continue...
Group Icon

Group: Admin
Posts: 3,467
Joined: 23-April 05
From: Trap17 storage box
Member No.: 6,042



What you mean by "ordered" as in it's not aligned with each other at all? This cannot be possible using just CSS or anything else because the character width of each letters, i.e. A, O, V, W, I, M and P.

The simplest way to resolve the alignment issue is to create LETTERS in graphics with all of them having the same width and height.

The method you should try is to align "Beginning with" and let LETTERS drift off

Beginning with A
Beginning with O
Beginning with V
Beginning with W
Beginning with I
Beginning with M
Beginning with P

And these would be enclosed within a DIV or TABLE and centered to a page...

The complicated way is to use CSS to set LETTERS as the same width with same space apart. But you may end up with 26 different cases to align them all in a line, not to mention they may not look all the same (some wider than others).
Go to the top of the page
 
+Quote Post
kraizii88z
post Mar 5 2007, 02:15 AM
Post #3


Advanced Member
*******

Group: [HOSTED]
Posts: 100
Joined: 19-February 07
From: Gahanna, Ohio
Member No.: 38,904



The only thing i could think of would be to justify a table and center it.

This post has been edited by kraizii8z: Mar 5 2007, 02:16 AM
Go to the top of the page
 
+Quote Post
rvalkass
post Mar 5 2007, 06:28 AM
Post #4


apt-get moo
Group Icon

Group: [MODERATOR]
Posts: 2,114
Joined: 28-May 05
From: Hertfordshire, England
Member No.: 7,593
Spam Patrol



I would put the entire list in a DIV, and set the text alignment within the DIV to justify. This will (obviously) justify the list. Then, if you set the left and right margins of the DIV to auto, then it will centre align the DIV within the parent element. This should give the look of a centre-aligned, justified list. I've tried it and it does work, although you have to fiddle around with the width of the DIV to get the look you want.
Go to the top of the page
 
+Quote Post
jlhaslip
post Mar 5 2007, 07:19 AM
Post #5


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,994
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



Is this any better?
Adjust the spacing by increasing the margin on the class.

CODE

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>An XHTML 1.0 Strict standard template</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link type="text/css" rel="stylesheet" href="./w3c_suggested.css" media="all" />

</head>
<style type="text/css">

.box {
margin: 0;
padding: 0em;

}
.centre {
margin: 0 2em;
text-align: center;
}
</style>


<body>

<div class="box">
<p class="box" >Beginning<span class="centre">with</span>&nbsp;A</p>
<p class="box" >Beginning<span class="centre">with</span>&nbsp;C</p>
<p class="box" >Beginning<span class="centre">with</span>&nbsp;V</p>
<p class="box" >Beginning<span class="centre">with</span>W</p>
<p class="box" >Beginning<span class="centre">with</span>&nbsp;&nbsp;I</p>
<p class="box" >Beginning<span class="centre">with</span>&nbsp;M</p>
<p class="box" >Beginning<span class="centre">with</span>&nbsp;P</p>
</div>
</body>
</html>


I placed a "non-breaking space" in the narrow glyphs and two in the "I". No adjustment to the 'W'. Might work?
Go to the top of the page
 
+Quote Post
Dagoth Nereviar
post Mar 11 2007, 09:03 PM
Post #6


Privileged Member
*********

Group: [HOSTED]
Posts: 537
Joined: 19-May 06
From: Leeds, UK
Member No.: 23,963



Thank you for all the replies biggrin.gif

My idea was to use a div, and then a table to align it, which looks like I will have to do.
I'll have to have the heading in a different div too, or else it won't work, right?
Go to the top of the page
 
+Quote Post
jlhaslip
post Mar 11 2007, 11:38 PM
Post #7


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,994
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



Just a reminder that tables do, in fact, have their uses, although it would appear that you are using the table in a structural way to format the data and that is not what tables are designed for. Using a table for this task is not "semantic" and alternatives should be considered.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Need Help On "global News" Problem.(7)
  2. Align Text Column Without Tables Using Css(13)
  3. Text Size Problem(6)
  4. Using Unknown Fonts For Text In Webpage(5)
  5. Problem Getting Text To Align With Different Resolutions(4)


 



- Lo-Fi Version Time is now: 6th September 2008 - 07:53 PM