473,382 Members | 1,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to make div expand with content?

I have 3 divs on a line, surrounded by a another div(wrapper?) The middle section is content, while the div to the left and right work as borders (images). The middle section expands as should, but the left and right won't follow it.

Expand|Select|Wrap|Line Numbers
  1.     <div id="frame_wrapper">
  2.           <div id="frame_left"></div>
  3.           <div id="frame_middle">
  4.  
  5.                 content bla bla
  6.  
  7.         </div>
  8.           <div id="frame_right"></div>
  9.     </div>
  10.  
The CSS:

Expand|Select|Wrap|Line Numbers
  1. #frame_wrapper {
  2.     top: -230px;
  3.     width: 944px;
  4.     position: relative;
  5.     z-index: 75;
  6.     border: 1px solid black;
  7.     }
  8.  
  9. #frame_left, #frame_right, #frame_middle {
  10.     background-repeat: repeat-y;
  11.     width: 22px;
  12.     margin: 0 auto;
  13.     overflow: auto;
  14.     }
  15.  
  16. #frame_right {
  17.     background-image: url(skin/new/frame_r.png);
  18.     float: right;
  19.     }
  20.  
  21. #frame_left {
  22. background-image: url(skin/new/frame_l.png);
  23. float: left;
  24. }
  25.  
  26. #frame_middle {
  27. background-color: #eeeeee;
  28. width: 900px;
  29.     }
As you can see, there are no height attributes. I've taken them out atm, because no one worked.


The CSS for the document is:
Expand|Select|Wrap|Line Numbers
  1. html, body { height: 100%; }
  2.  
  3. /* if you remove this then the container disappears in IE */
  4. * html #container {
  5. height: 99%;

Thankful for replies
Dec 10 '10 #1
5 5458
Dormilich
8,658 Expert Mod 8TB
The middle section is content, while the div to the left and right work as borders (images).
why should they. the do not contain any content (right now), so the height should be 0.

not sure whether it is the best solution, but one that I got working is using nested <div>s and appropriate padding.
Expand|Select|Wrap|Line Numbers
  1. <div id="right">
  2.     <div id="left">
  3.         <div id="content">
  4. <!-- your content -->
  5.         </div>
  6.     </div>
  7. </div>
Expand|Select|Wrap|Line Numbers
  1. /* fill in your values */
  2. #right {
  3.     padding-right: 
  4.     background-image:
  5.     background-position:
  6.     background-repeat:
  7. }
  8. #left {
  9.     padding-left: 
  10.     background-image:
  11.     background-position:
  12.     background-repeat:
  13. }
Dec 10 '10 #2
Death Slaught
1,137 1GB
If I'm not mistaken it's impossible to have all three divisions expand equally, when one has more content than the others with HTML and CSS alone.


Regards, Death
Dec 10 '10 #3
Thanks guys.
So if it's impossible, what do people do in this situation?
Merge the 3 into one, wide image that's being stretched, or the use of tables?

I tried Dormilich's method and I didn't quite make it work, though I'm still at it.
Dec 10 '10 #4
JKing
1,206 Expert 1GB
Javascript would be the solution. Get the height of the tallest column and apply it to the other columns.

I think I asked this in another thread but are you using a fixed width on your content column? You have declared a 900px width but is this just for your example or for your actual project?
Dec 10 '10 #5
The width is for the actual project. :)

I have made a fix a the moment.. I've merged the 2 border images with the middle section so that it's an image being stretched (the images were made for stretchyness anyway).
Dec 10 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: clintonG | last post by:
Can somebody direct me to documents or source that supports the use of collapsible content that is collapsed by default when the page is loaded? The secondary objective would of course be...
7
by: peter | last post by:
I use the click-to-expand menu at http://javascript.internet.com/navigation/click-to-expand-menu.html This works fine, but is there a way to expand or collapse all the menus? An example of how...
7
by: Andrew Robinson | last post by:
Given HTML text (likely from SQL), is there any method that could be employed to render server and/or custom controls that are contained inside of that text? I would be loading content from a...
11
by: Nospam | last post by:
I don't know what it is I am doing wrong, I am trying to get the menus to either expand or contract based on their previous states, i.e if already expanded if clicked again contract, and if...
0
by: Homer J. Simpson | last post by:
A few weeks ago I asked for suggestions on how to persist a tree's node state to cookies, without causing postbacks on each click in the tree. I had a single .aspx file, with a row of buttons on...
4
by: ge5talt | last post by:
Longtime reader, 1st time poster :) I am in the process of overhauling a website and replacing an old table-based quirksmode layout with a standards-mode tableless one. I am currently working on...
2
by: cshaw | last post by:
Hello Everyone, I am having problems with a listbox control. I have a page with a couple of labels and drop-down lists at the top, and then below there is a table with two columns, the first column...
6
by: AJM Project | last post by:
Hello, I see this is a well known thing and have seen many answers but none have worked for me. It's just a test page I'm making and I've ran into this so I thought I'd ask how to fix it - inline...
3
by: unpresedented | last post by:
I have a table with one TR and two TDs, one of the TDs has more content (i mean with content: other sub tables) than the other one, this results the following: the TD with the little content stay...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.