?
Solved

Vertically centered element

Posted on 2006-06-26
6
Medium Priority
?
318 Views
Last Modified: 2013-11-19
I am not sure if this is possible.

How do you position an element, lets say a table, vertically centered on a page?  No scrollbars.
0
Comment
Question by:rodmjay
[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
6 Comments
 
LVL 37

Accepted Solution

by:
Harisha M G earned 672 total points
ID: 16988601
Hi,

For the body element, add the "vertical-align" style..

<body style="vertical-align: middle">
...


---
Harish
0
 
LVL 7

Assisted Solution

by:maUru
maUru earned 664 total points
ID: 16988632
0
 
LVL 37

Expert Comment

by:Harisha M G
ID: 16988652
maUru, good point !

rodmjay, refering to the link sent by maUru, the style should be

<body style="display:table-cell; vertical-align: middle">

0
 
LVL 10

Assisted Solution

by:jagadeesh_motamarri
jagadeesh_motamarri earned 664 total points
ID: 16989420
Well.......here is a post that i've answer earlier this month. It was accecpted.....Take a look at this ... http://www.experts-exchange.com/Web/Web_Languages/CSS/Q_21888464.html

......................Same thing copied here...............
Hi digitalpacman,

Here is a nice article on what you are looking for. Don;t forget to see the examples which contains your solutions

URL: http://www.badboy.ro/articles/2005-02-20/index.php

I wouldn't mind copying the code for you.

Here it goes:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Middle align test - multiple lines</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Author" content="Lucian Slatineanu, http://www.badboy.ro/" />
<style type="text/css" media="screen">
<!--
p {
     margin:0;
     padding:0;
}
#wrapper {
     width:550px;
     border:1px solid #666;
     padding:10px;
     height:300px;
}
#fixed {
     float:right;
     width:200px;
     height:300px;
     background:#666;
     display:block;
}
#wrapper>#floating { /*display:table for Mozilla & Opera*/
     display:table;
     position:static;
}
#floating { /*for IE*/
     width:300px;
     height:100%;
     background:#EAEAEA;
     position:relative;
}
#floating div { /*for IE*/
     position:absolute;
     top:50%;
}
#floating>div { /*for Mozilla and Opera*/
     display:table-cell;
     vertical-align:middle;
     position:static;
}
#floating div div {
     position:relative;
     top:-50%;
}
-->
</style>
</head>

<body>
<div id="wrapper">
     <img src="0.gif" alt="stuff" id="fixed" />
     <div id="floating"><div><div>

          <p>Middle aligned text goes right here and it does wrap nicely at the end of the line</p>
     </div></div></div>
</div>
</body>
</html>


______Jags.
0

Featured Post

Industry Leaders: 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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…
Suggested Courses

777 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