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
Solved

Vertically centered element

Posted on 2006-06-26
6
305 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
  • 2
6 Comments
 
LVL 37

Accepted Solution

by:
Harisha M G earned 168 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 166 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 166 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Crazy text will not be removed no matter what I try! 13 34
A simple Float not working. 5 25
Testing Responsiveness for Different Devices 4 36
tiny glitch in my main slider 3 38
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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?
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

766 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