div in middle....?
#1
Posted 24 February 2006 - 08:34 AM
#2
Posted 24 February 2006 - 08:46 AM
Edit Again: Ok I found these resources for ya:
http://www.quirksmod.../centering.html
http://www.wpdfd.com...03.htm#footnote
http://www.jakpsatweb.cz/css/css-vertical-...r-solution.html
Also to aide even further in your search try looking for "css vertical centering"
Good Luck
Edited by raenef, 24 February 2006 - 09:00 AM.
#3
Posted 24 February 2006 - 09:56 AM
if you already know css just look at the source code.
#4
Posted 24 February 2006 - 10:29 AM
#5
Posted 24 February 2006 - 11:23 AM
#6
Posted 24 February 2006 - 07:34 PM
#7
Posted 24 February 2006 - 11:21 PM
body {
v-align: center;
}
Clearly a lot shorter and simpler than their suggestion.
#8
Posted 24 February 2006 - 11:30 PM
#9
Posted 25 February 2006 - 11:11 AM
Edited by greg, 25 February 2006 - 11:11 AM.
#10 _*Speed_*
Posted 25 February 2006 - 01:45 PM
davidandersson, on Feb 24 2006, 07:29 AM, said:
If you resized your browser on the site that coolaid linked to, then it should automatically resize it. I think it really is resizing it, but the image you are displaying might be too large, therefore does not look correctly positioned on your screen.
Here is the css you actually need if you are going to use the site coolaid linked to as your guide.
#horizon
{
color: white;
background-color: #0ff;
text-align: center;
position: absolute;
top: 50%;
left: 0px;
width: 100%;
height: 1px;
overflow: visible;
visibility: visible;
display: block
}
#content
{
font-family: Verdana, Geneva, Arial, sans-serif;
background-color: #f00;
margin-left: -125px;
position: absolute;
top: -35px;
left: 50%;
width: 250px;
height: 70px;
visibility: visible
}
.bodytext
{
font-size: 14px
}
.captions
{
color: white;
font-size: 10px;
line-height: 14px;
font-family: Verdana, Geneva, Arial, sans-serif;
text-align: left
}
#caption1
{
padding-left: 6px;
border-left: 1px dashed #66c;
position: absolute;
top: -80px;
left: -200px;
width: 250px;
height: 80px;
visibility: visible;
display: block
}
#caption2
{
padding-left: 6px;
border-left: 1px dashed #66c;
position: absolute;
top: 92px;
left: 125px;
width: 250px;
height: auto;
visibility: visible;
display: block
}
The "caption" arent really necessary unless you want to use it as intended on the site.Here is the html code:
<div id="horizon"> <div id="content"> <div class="bodytext"><div id="caption1" class="captions">The cyan box 'horizon' is positioned absolutely 50% from the top of the page, is 100% wide and has a nominal height of 1px. Its overflow is set to 'visible'.</div> This text is<br> <span class="headline">DEAD CENTRE</span><br> and stays there! <div id="caption2" class="captions">The red 'content' box is nested inside the 'horizon' box and is 250px wide, 70px high and is positioned absolutely 50% from the left - but has a negative margin that is exactly half of its width, -125px. To get it to centre vertically, it has a negative top position that is exactly half of its height, -35px.</div> </div> </div> </div>
This is the entire code
<style type="text/css" media="screen"><!--
#horizon
{
color: white;
background-color: #0ff;
text-align: center;
position: absolute;
top: 50%;
left: 0px;
width: 100%;
height: 1px;
overflow: visible;
visibility: visible;
display: block
}
#content
{
font-family: Verdana, Geneva, Arial, sans-serif;
background-color: #f00;
margin-left: -125px;
position: absolute;
top: -35px;
left: 50%;
width: 250px;
height: 70px;
visibility: visible
}
.captions
{
color: white;
font-size: 10px;
line-height: 14px;
font-family: Verdana, Geneva, Arial, sans-serif;
text-align: left
}
#caption1
{
padding-left: 6px;
border-left: 1px dashed #66c;
position: absolute;
top: -80px;
left: -200px;
width: 250px;
height: 80px;
visibility: visible;
display: block
}
#caption2
{
padding-left: 6px;
border-left: 1px dashed #66c;
position: absolute;
top: 92px;
left: 125px;
width: 250px;
height: auto;
visibility: visible;
display: block
}
body {
background-color: #333333;
}
--></style>
<div id="horizon">
<div id="content">
<div class="bodytext">
<div id="caption1" class="captions">Here is the example </div>
<p>You can put text here to center it.<br>
Or you can place an image.<br>
<img src="http://www.pixel2life.com/images/header_logo.gif" width="276" height="93"></p>
</div>
</div>
</div>
#11
Posted 25 February 2006 - 08:51 PM
body
{
margin: 0 auto;
text-align: center;
/* Blah Blah Blah */
}
#THE_CENTERED _THING
{
margin: 0 auto;
/* Blah Blah Blah */
}
dEcade
Edited by dEcade, 25 February 2006 - 10:36 PM.
#12
Posted 25 February 2006 - 10:22 PM
#13
Posted 25 February 2006 - 10:37 PM
dEcade
#14
Posted 25 February 2006 - 11:09 PM
vertical-align does exist: http://www.w3schools...tical-align.asp
And the auto margin does work in IE, you just have to make sure the element has a width (img elements don't count): http://www.w3.org/St...007/center.html (coincedently, this link has a tutorial on vertical centering, unfortunately, it doesn't work in IE)
Edited by rc69, 25 February 2006 - 11:10 PM.
#15
Posted 26 February 2006 - 12:12 PM
Edited by greg, 26 February 2006 - 12:13 PM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
