Topic: Contrain DIV Width to IMG Width (Page 1 of 1) |
|
---|---|
Paranoid (IV) Mad Scientist From: Inside THE BOX |
posted 09-20-2003 03:45
Please take a look at this. |
Maniac (V) Inmate From: Den Haag: The Royal Residence |
posted 09-20-2003 12:22
On a dutch forum we had a simular discussion about two div's who should have the same height. Here there was one menu and one content div. After some realy strange javascript and php scripts it turned out to be a very simple solution. Look at this site: http://www.xs4all.nl/~sbpoley/webmatters/layout3.html . code: .image{ code: <div class=caption>
|
Paranoid (IV) Inmate From: A graveyard of dreams |
posted 09-20-2003 18:03
Rinswind's solution seem to be the easiest (and best) one. It is also the same solution that w3c has demonstrated on their Tips and Tricks page. |
Paranoid (IV) Mad Scientist From: Inside THE BOX |
posted 09-22-2003 00:24
It looks like this would solve things if my problem were one DIV expanding to the size of the other DIV, but my problem is constraining the size of a DIV. I don't want the caption pushing beyond the width of the image and I can't manually define the width of every DIV on every page. (All the images have different widths.) |
Maniac (V) Inmate From: under the bed |
posted 09-22-2003 03:46
If you have PHP available you can do this easily. |
Maniac (V) Inmate From: Den Haag: The Royal Residence |
posted 09-22-2003 23:46
Here is what i understood: |
Paranoid (IV) Inmate From: A graveyard of dreams |
posted 09-23-2003 00:15
Rinswind: If I understoor you right your stylesheet/code would make the divs look like this: |
Paranoid (IV) Mad Scientist From: Inside THE BOX |
posted 09-23-2003 15:03 |
Maniac (V) Inmate From: Den Haag: The Royal Residence |
posted 09-23-2003 19:12
Ok now i see my mistake, stupid Trying to use a relative width does not help since that means relative to the containing div. Darn. Anyway it's pretty odd, when there is no width specified, the width (or height) will be defined by the content but if you specify a relative width it's defined by the containing element.....weird |
Paranoid (IV) Inmate From: Minneapolis, MN, USA |
posted 09-23-2003 21:22
It seems weird when you're expecting it the other way, but think about it, usually you would expect it to be the way it is. For instance if you make a page with a main content DIV and set the div width to 85% you expect it to be 85% of the browser window, not 85% of however long its contents would be if they were unconstrained. Now THAT would be weird. |
Paranoid (IV) Mad Scientist From: KC, KS |
posted 09-25-2003 15:31
Instead of going back to tables why not just use the solution that DL proposed? Use an inline style to control the width of each div individually. It's not exactly the most elegant solution but it'll work. |
Paranoid (IV) Mad Scientist From: Inside THE BOX |
posted 09-25-2003 15:44 |