7 replies [Last post]
Natdizzle
Natdizzle's picture
Offline
newbie
Old North Sacramento
Last seen: 6 years 18 weeks ago
Old North Sacramento
Timezone: GMT-7
Joined: 2013-07-13
Posts: 5
Points: 6

Tongue <div style="width:500px;height:500px;><div style="width: 500px">this div needs to be as high as the first div, what code to i add to do that i have tried "width:100%"</div></div>

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 2 days 20 hours ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5342
Points: 2963

Hi Natdizzle, you shouldn't

Hi Natdizzle,
you shouldn't need anything on the inner div for it's width to fill the available space, unless you have changed the display property or floated it.

Natdizzle
Natdizzle's picture
Offline
newbie
Old North Sacramento
Last seen: 6 years 18 weeks ago
Old North Sacramento
Timezone: GMT-7
Joined: 2013-07-13
Posts: 5
Points: 6

the height

Wink okay right, now what about the height of the inner div? say the outer div gets changed to <div style="min-height: 500px;"> then content fills up that div so it stretches to 750px height, then the inner div needs to match that height, but sinc e the content filled it up we have no idea what the exact height will be every time. i tried height:100%, height:inherit, margin:auto

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 2 days 20 hours ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5342
Points: 2963

i'm not really following. Is

i'm not really following. Is there a problem with not knowing the actual height?
Have you looked at overflow

Natdizzle
Natdizzle's picture
Offline
newbie
Old North Sacramento
Last seen: 6 years 18 weeks ago
Old North Sacramento
Timezone: GMT-7
Joined: 2013-07-13
Posts: 5
Points: 6

well i was looking for a way to have the inside div

automaticly scroll or resize to the outside divs height as it expands but i might have to just set a background image behind the inside div instead of the inside div itself so the image will repeat verticly th e size of the outside div unless i can figure out a wway to have the inside div expand verticly with the outside div Smile

Natdizzle
Natdizzle's picture
Offline
newbie
Old North Sacramento
Last seen: 6 years 18 weeks ago
Old North Sacramento
Timezone: GMT-7
Joined: 2013-07-13
Posts: 5
Points: 6

you know what i did

since i needed a background image on the inside div to tile verticly as high as the outsive div, i just put the background imag e on th e outside div instead

Natdizzle
Natdizzle's picture
Offline
newbie
Old North Sacramento
Last seen: 6 years 18 weeks ago
Old North Sacramento
Timezone: GMT-7
Joined: 2013-07-13
Posts: 5
Points: 6

forgot to mention it was a floating div

otherwise i think thats right

surajnaikin
surajnaikin's picture
Offline
Enthusiast
india
Last seen: 4 years 38 weeks ago
india
Timezone: GMT+5.5
Joined: 2007-06-09
Posts: 111
Points: 72

let the content inside work

Usually, heights are never given unless specifically needed. The content over the web is suppose to expand, so let the content do the job, IF your inner div has content, if it expands the outer div too. Why would the outer div will increase its height on its own, unless you CSSify it or it has content inside.

But still if you need specific height,

divouter - height fixed
divinner - 100%

Logic should work.

<div style="height:500px; width:500px; background:red; padding:10px">
  <div style="height:100%; background:green"></div>
</div>