Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
div size dependent on children divs
Old 07-10-2007, 08:35 AM div size dependent on children divs
manuleka's Avatar
Average Talker

Posts: 18
Name: manu leka
Trades: 0
just wondering if anyone can tell me how to make the div size (height in my case) be dependent on the size and amount of children divs it has....

for the case of my codes below, the div id="menumain" overlaps over the borders of it's parent div id="contents"

check the result on http://www.nutstuff.net

css:
Code:
<html>
	<head>
		<meta http-equiv="page-enter" content="progid:dximagetransform.microsoft.pixelate(duration=3)" />
		<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
		<meta name="author" content="nutstuff.net" />
		<meta name="keywords" content="web design, web development, simple it solutions" />
		<meta name="description" content="simple web and it solutions" />
		<title>NutStuff - Home</title>
		<style type="text/css">
			div{
				position:absolute;
				}
			div#mainlogo{
				/* MAIN LOGO */
				top:0;
				left:50%;
				margin-left:-370px;
				width:740px;
				height:100px;
				background-image:url('imgs/nutstuff.gif');
				}
			div#contents{
				top:110px;
				left:50%;
				margin-left:-370px;
				padding:10px;
				width:719px;
				height:auto;
				border:1px solid #c0c0c0;
				border-top:25px solid #c0c0c0;
				color:#000;
				font-family:tahoma;
				font-size:11px;
				font-weight:bold;
				}
			div#contents div#menumain{
				position:absolute;
				top:0px;
				left:540px;
				width:180px;
				height:250px;
				margin-top:10px;
				border:1px solid #c0c0c0;
				background-color:#e0e0e0;
		</style>
html:
Code:
		<div id="mainlogo">
			<img src="imgs/ad1.gif" alt="your closest to free web start!" />
		</div>
		<div id="contents">
				Welcome to nutstuff.net, our site is under construction!<br />
				Please visit again sometime soon<br /><br />
				Nut Stuff crew<br /><br />
				<?php
					print "<span style=\"font-weight:normal;\">\n\t\t\t\tthis line is for testing htaccess script\n\t\t\t</span>";
				?>
					<br /><br />
				<span style="text-align:center;">
						<a href="http://validator.w3.org/check?uri=referer">
						<img src="imgs/validxhtml1.0.png" alt="Valid XHTML 1.0 Transitional" height="31" width="88" border="0" />
						</a>
				</span>
			<div id="menumain">
				BROWSING LINKS GO HERE
			</div>
		</div>
manuleka is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-10-2007, 12:20 PM Re: div size dependent on children divs
angele803's Avatar
Perfectly Imperfect

Posts: 1,772
Name: Stephanie
Location: Oklahoma
Trades: 2
Im not sure if this is the correct way to handle this problem, but I tested it out and it works. If you declare a min-height for your container div, it seems to solve the problem. You can just add min-height:100% to #contents.
Also, I dont think you need to put "div" in front of the divs you declare. You have "div#contents", but you should be able to just put "#contents".
It also looks like you are trying to center everything with absolute positioning. It might be easier for you to just put everything in a container div and put "margin: auto" on it.
angele803 is offline
Reply With Quote
View Public Profile
 
Old 07-10-2007, 02:23 PM Re: div size dependent on children divs
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
Quote:
just wondering if anyone can tell me how to make the div size (height in my case) be dependent on the size and amount of children divs it has....
There's really nothing to it.. a div will automatically stretch to contain it's children. If the container is floated, then you must make sure the float is cleared.

Min-height is not supported by IE 6, so min-height will only work in other browsers. To make IE work you would have to have a separate CSS file for IE 6 and below and feed it just height: 100%. You'd need to use conditional comments to call the IE only CSS file.

Your problem is the position:absolute. Since absolute positioning takes those elements OUT of the document flow, regardless of how big they are, they will NOT affect any other element around them.

Get rid of the position:absolute and you should solve you problem. You may have to use floats instead to achieve your layout - which is a better solution anyway.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to div size dependent on children divs
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.52037 seconds with 12 queries