• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

CSS question

I have this page > http://quickgoldfoils.com/

I know margin: 0 auto will center a div item horizontally but is there any way to center it vertically? IE same amount of height on top as on the bottom?

THanks!
0
lvollmer
Asked:
lvollmer
2 Solutions
 
Dave BaldwinFixer of ProblemsCommented:
'Auto' works... if you have a defined height to center it in.  If you try to put it in the center of a page without a defined height, it technically works... but since it is the only content providing any height, 'auto' top and bottom means effectively nothing.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>Auto Margin</title>
<style type="text/css">
<!-- 
.boxit {
	width:400px;
	height:400px;
	}
.inbox {
	margin: auto;
	background-color: #ddeeff;
	width:200px;
	height:200px;
	}	 
-->
</style>
</head>
<body>
<h1>Auto Margin</h1>

<table border="1" cellpadding="0" cellspacing="0" summary="">
<tr><td class="boxit">
<div class="inbox">Here</div>
</td></tr>
</table>

</body>
</html>

Open in new window

0
 
codefluxCommented:
align="center" valign="middle"

<table border="1" cellpadding="0" cellspacing="0" summary="">
<tr><td class="boxit" align="center" valign="middle">
<div class="inbox">Here</div>
</td></tr>
</table>

Open in new window

0
 
lvollmerAuthor Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now