Derleek Posted April 27, 2009 Share Posted April 27, 2009 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! Quote Link to comment Share on other sites More sharing options...
jackpf Posted April 27, 2009 Share Posted April 27, 2009 Just a guess, but that might be because images are a certain px, so cannot resize themselves. I think javascript would be the best thing for this. Quote Link to comment Share on other sites More sharing options...
Derleek Posted April 27, 2009 Author Share Posted April 27, 2009 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. Quote Link to comment Share on other sites More sharing options...
Dragen Posted April 28, 2009 Share Posted April 28, 2009 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 Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted April 29, 2009 Share Posted April 29, 2009 height: 100%; height: auto; shrink wraps it. Quote Link to comment Share on other sites More sharing options...
Derleek Posted April 29, 2009 Author Share Posted April 29, 2009 ugh... that makes sense.... change your name to css God. I swear you've helped on nearly all of my css issues Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.