473,549 Members | 3,099 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.dt d">

<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 1596
On Jun 19, 9:22 pm, rowe_newsgroups <rowe_em...@yah oo.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.dt d">

<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.dt d">

<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
26849
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
6182
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 work in a certain way (like some should scroll with a fixed background and others shouldn't scroll bla bla..) and the divs are nested and positioned...
1
3471
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 the sidebar (right) doesn't center here's the css i'm modifying to center it. i apologise for the mess. <html> <head> <title>cris-kun's 'Blog -...
24
3588
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 show what I'm talking about. http://screencast.com/t/i5SLg3cAczH (*WARNING, TAKES A WHILE TO LOAD*) *HTML* <html> <head> <title>James Mann...
0
7520
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7446
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7718
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7956
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7809
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5368
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.