Jump to content

[SOLVED] height inheritance


Derleek

Recommended Posts

Hey guys...

 

I have a image that displays next to the content of a website.  I would like this image to expand or contract depending on the height of my content div.  I am confused because setting the height of the img div to 'auto' does not work!

 

code:

HTML -

<div id='content'>
<div id='divider'></div>
   Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam lacinia sollicitudin ante. Nullam rhoncus placerat dolor. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;
</div>

CSS -

#divider
{
background: transparent url('../img/menu_background2.jpg') repeat-y top right;
width: 3px;
height: auto;
margin-left: -20px;
position: absolute;
}

 

I could very easily use JS to do this but i'd rather not.  Shouldn't the 'content' div's height be inherited by the divider div?

 

Thanks for any advice!

 

Link to comment
Share on other sites

Its not the image i'm trying to resize the image... just the div.  The css: 'background: transparent url('../img/menu_background2.jpg') repeat-y top right;' makes the image repeat down the divider div.  But for some reason the divider div does not inherit the height of the content div, even though it is nested.

 

I'm trying to make the divider div adjust to the content divs height... sorry if this wasn't clear before.

Link to comment
Share on other sites

could you just remove the divider div, and have the divider image in the 'main' dive, or whatever it is dividing?

Then just add some padding-left to the div so that its contents are not displayed on top of the image:

.left{
padding-left:'WIDTH OF menu_background2.jpg HERE'px;
background:url('../img/menu_background2.jpg') 0px 0px repeat-y transparent;
}

 

<div>some content></div>
<div class="left">other content</div>

 

That way, the image will always go from top to bottom, whatever the height of the div :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.