?
Solved

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

Posted on 2008-10-14
2
Medium Priority
?
1,233 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 1000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

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.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

762 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