Solved

How can i make the text vertical align middle in span box?

Posted on 2008-10-14
2
1,220 Views
Last Modified: 2012-05-05
hi,

how can i make the following box's text align vertical middle?

thanks
<span style="border: 2px solid purple;
			width: 10em;
			height: 10em;
			margin: 2px;
			display: inline-block;
			vertical-align: middle;
			text-align: center;
			overflow: hidden;">1 2 3 4 5 6 7 8 9 _ 1 2 3 4 5 6 7 8 9 _ 1 2 3 4 5 6 7 8 9 _ 1 2 3 4 5 6 7 8 9 _ 1 2 3 4 5 6 7 8 9 _ </span>

Open in new window

0
Comment
Question by:Valimai
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 44

Accepted Solution

by:
scrathcyboy earned 250 total points
ID: 22717730
SPAN is usually for inline text, not for block level container alignment.  If you want to vertically align text in this, you are better to use a DIV than a span.  There are many ways to do this for DIV, see these --

http://webdesign.about.com/od/beginningcss/a/aa012207.htm
http://www.hicksdesign.co.uk/journal/how-to-vertical-centering-with-css
www.zoffix.com/zoffix/css/vertcenter.shtml
http://phrogz.net/CSS/vertical-align/index.html

basically the vertical-align: middle; does it for a DIV
    .vcenter {
      min-height: 12em;
      display: table-cell;
      vertical-align: middle;
    }
 
    <div class="vcenter">
    <p>This text is vertically centered in the box.</p>
    </div>

Open in new window

0
 
LVL 1

Author Comment

by:Valimai
ID: 22717955
hi,

the following works in firefox but not IE. the following link you provided me gives an IE fix using wrappers. So much code, so looks like i wont use it.
www.zoffix.com/zoffix/css/vertcenter.shtml

thanks for your help.
<div style="
		border: 2px solid purple;
		width: 10em;
		height: 10em;
		display: table-cell;
		vertical-align: middle;">
		<p>1 2 3 4 5 6 7 8 9 _ 1 2 3 4 5 6 7 8 9 _ 1 2 3 4 5 6 7 8 9 _ 1 2 3 4 5 6 7 8 9 _ 1 2 3 4 5 6 7 8 9 _</p>
</div>

Open in new window

0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Find out what you should include to make the best professional email signature for your organization.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question