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.

CSS Forum


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



Reply
nested css div expansion
Old 05-18-2006, 06:44 PM nested css div expansion
Novice Talker

Posts: 6
Trades: 0
Hi guys I was wondering if anyone on here could give me a hand..... I would be really grateful if they could......

Here goes....

I have 3 div tags.

One is postioned relatively as a background.

The other 2 area nested inside this (relatively).

When I move the postions of the inner div tags using css the parent one does not resize (expand) to encompass them.

I want to create a background div that expands and shrinks as new content is added to the page.

Is what i am trying possible?

Many thanks ;]

Jim.

Last edited by alpha_juno; 05-18-2006 at 06:45 PM..
alpha_juno is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-18-2006, 06:46 PM Re: nested css div expansion
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
show some code.

but it sounds like you have set an explicit height on the parent container
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-18-2006, 06:53 PM Re: nested css div expansion
Novice Talker

Posts: 6
Trades: 0
many thanks for the help ;]

css:

Code:
#background_layer {
 background: #FFFFFF;
 position: relative;
 top: 10px;
 left: 10px;
 background-image: url(../lib/global/background_x750.jpg);
 background-repeat: no-repeat;
 background-position: left top;
 width: 750px;
 }
#top_left {
  position: relative;
  top: 0px;
  left: 0px;
}
#uttery_adventurous {
  position: relative;
  top: 0px;
  left: 10px;
}
#book_tokens {
  position: relative;
  top: 5px;
  left: 0px;
}
#top_right {
  position: relative;
  height: 200px;
  top: -180px;
  left: 497px;
}
#little_heroes {
  position: relative;
  top: 0px;
  left: 0px;
}
#find_out_more {
  position: relative;
  top: 80px;
  left: 0px;
}

html:

HTML Code:
 
<div id="background_layer">
 
<div id="top_left">
<div id="uttery_adventurous"><a href="http://www.XXXXXXX.com"><img src="./lib/global/uttery_adventurous.gif" alt="Utterly Adeventurous!" /></a></div>
<div id="book_tokens"><a href="http://www.XXXXXXXXXX.com"><img src="./lib/global/book_tokens.gif" alt="Personalised Book offer." /></a></div>
</div>
 
<div id="top_right">
<div id="little_heroes"><img src="./lib/global/little_heroes.gif" alt="We'll make your little heroes the stars of our books." /> </div>
<div id="find_out_more"><a href="more.php?pid=<?=$_GET['pid']?>"><img src="./lib/global/find_out_more.gif" alt="Show me more about <?=$ptp[0]['productName']?>." /></a> </div>
</div> 
</div>
 

Last edited by alpha_juno; 05-18-2006 at 08:05 PM..
alpha_juno is offline
Reply With Quote
View Public Profile
 
Old 05-18-2006, 07:37 PM Re: nested css div expansion
Novice Talker

Posts: 6
Trades: 0
Ok guys I think i figured it out. I am by no means an expert on this so please forgive any novice mistakes....

I wrote this, hopefully it can be expanded and improved upon and hopefully it will help out someone else!



Using nested divs to acheive an expanding (height) background as new content is added.

Set your background div to relative (positioning). Position it as you please and set
its min-height (to your desired normal (unexpanded) page height in px).

Note: Any more relative divs you add to the page will be included in the height math that governs the expansion of the background div. So set all divs other than the one you wish to use to expand the page to absolute.

Make sure the div you wish to use to expand the page is the first div nested inside the background div. If it is not first the expansion will not happen. Set its
postioning to "top: 0px;". Use padding to achieve the position you wish to offset it from the top of the page. Set bottom padding to create some distance between the end of the page and the end of the div.

As you add content to this div the page should expand.

Now add the rest of your page elements using absolute positioning.

Cheers,

Jim;]

Last edited by alpha_juno; 05-18-2006 at 07:38 PM..
alpha_juno is offline
Reply With Quote
View Public Profile
 
Old 05-19-2006, 01:40 AM Re: nested css div expansion
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
Jim the basic problem was by having all the nested divs positioned in some way they were taken out of the normal document flow and in a way weren't really inside the containing div.

You just need to have the one div you want to control the overall expansion to remain in the document flow so no positioning. You want to control where it is in the layout with a margin or a padding like you did. It shouldn't matter where in the order it comes though.

Sounds like you got it all worked out, but hopefully I explained a little about why it was happening.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 05-19-2006, 12:43 PM Re: nested css div expansion
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
It's definitely not necessary to position every single div, it's better that you don't. Position your main 'wrapper' as relative and leave the ones inside it alone to flow normally.
__________________
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
 
Old 05-19-2006, 03:46 PM Re: nested css div expansion
Novice Talker

Posts: 6
Trades: 0
ok guys so ill try doing the whole technique with padding. thanks for the comments ;]

cheers,

Jim;]
alpha_juno is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to nested css div expansion
 

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 2.67535 seconds with 12 queries