473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Center Div Not Filling Height

Hello all, I have something I believe is something simple, but I can't
seem to figure out what to do. I did some searching, but I either
can't get my search right.

Anyways, on a new webpage I'm creating (I'm not a designer by any
means) I want to have a Div in the center that hoses all the pages
content. I want the div to fill the entire height of the browser so I
set the css height to 100%, but when another object is downscreen, the
center div no longer fills the browser. Any suggestions on how to get
the center div to fill the height in this situation?

Here's some markup that will demonstrate the problem:

/////////////////////////////////////////

<%@ Page Language="C#" %>

<!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 runat="server">
<title>My Problem Page</title>
<style type="text/css">
body {
background-color: Black;
}

#centerDiv {
background-color: White;
position: absolute;
top: 0px;
left: 20%;
width: 60%;
height: 100%;
}

#problemDiv {
background-color: Red;
position: absolute;
top: 2000px;
left: 50%;
width: 100px;
height: 100px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="centerDiv">
<div id="problemDiv">

</div>
</div>
</form>
</body>
</html>

///////////////////////////////////////

Thanks in advance for all your help!

Thanks,

Seth Rowe

Jun 20 '07 #1
2 1590
On Jun 19, 9:22 pm, rowe_newsgroups <rowe_em...@yahoo.comwrote:
Hello all, I have something I believe is something simple, but I can't
seem to figure out what to do. I did some searching, but I either
can't get my search right.

Anyways, on a new webpage I'm creating (I'm not a designer by any
means) I want to have a Div in the center that hoses all the pages
content. I want the div to fill the entire height of the browser so I
set the css height to 100%, but when another object is downscreen, the
center div no longer fills the browser. Any suggestions on how to get
the center div to fill the height in this situation?

Here's some markup that will demonstrate the problem:

/////////////////////////////////////////

<%@ Page Language="C#" %>

<!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 runat="server">
<title>My Problem Page</title>
<style type="text/css">
body {
background-color: Black;
}

#centerDiv {
background-color: White;
position: absolute;
top: 0px;
left: 20%;
width: 60%;
height: 100%;
}

#problemDiv {
background-color: Red;
position: absolute;
top: 2000px;
left: 50%;
width: 100px;
height: 100px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="centerDiv">
<div id="problemDiv">

</div>
</div>
</form>
</body>
</html>

///////////////////////////////////////

Thanks in advance for all your help!

Thanks,

Seth Rowe
Instead of using a div to draw the content region, I've opted to just
draw the white background onto the page background and then center the
image. I'm still curious as to how to have the div fill, but at least
I have something working now.

Thanks,

Seth Rowe

Jun 20 '07 #2
its because you are using xhtml instead of ie quirks mode. in xhtml the
page does not have a height by default, so setting the div to 100% has
no effect. the div needs a parent with an absolute height. you can use
javascript to set the height.
-- bruce (sqlwork.com)
rowe_newsgroups wrote:
Hello all, I have something I believe is something simple, but I can't
seem to figure out what to do. I did some searching, but I either
can't get my search right.

Anyways, on a new webpage I'm creating (I'm not a designer by any
means) I want to have a Div in the center that hoses all the pages
content. I want the div to fill the entire height of the browser so I
set the css height to 100%, but when another object is downscreen, the
center div no longer fills the browser. Any suggestions on how to get
the center div to fill the height in this situation?

Here's some markup that will demonstrate the problem:

/////////////////////////////////////////

<%@ Page Language="C#" %>

<!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 runat="server">
<title>My Problem Page</title>
<style type="text/css">
body {
background-color: Black;
}

#centerDiv {
background-color: White;
position: absolute;
top: 0px;
left: 20%;
width: 60%;
height: 100%;
}

#problemDiv {
background-color: Red;
position: absolute;
top: 2000px;
left: 50%;
width: 100px;
height: 100px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="centerDiv">
<div id="problemDiv">

</div>
</div>
</form>
</body>
</html>

///////////////////////////////////////

Thanks in advance for all your help!

Thanks,

Seth Rowe
Jun 20 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: john T | last post by:
Is there anyway to vertically center a html table using css in such a way it does not alter the html table. When I tryied it just screws up.
19
roula
by: roula | last post by:
I HATE DIVS AND DIFFERENT BROWSERS!!! i spent the whole day and night searching for a way to center align stupid divs, the problem is that the code is so sensitive, i lost my mind trying to make them...
1
by: judacris | last post by:
I've seen the threads here about molding 2 divs in a centered fashion. but I can't seem to solve this thing. my blogger blog is functioning well on my site for now, but the blog feed (left) and...
24
by: GloStix | last post by:
I'm trying to center this banner, it's in a div that has the same width so it's not exactly "centering" but it's screwed up, It works in safari but in Firefox it's messed up. I uploaded a Video to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.