[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
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…

656 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