I am trying to set the width of a div element based on the size of an image that is within the div. I also have a text caption below the image in this same div and if the line goes longer than the width of the image than the div will be resized so that it doesn't fit so nicely around the image.
I don't want to define the width of the div because the image contained will vary in size.
I want to be able to specify that the div should only be as wide as the image and force the text to break and start new lines below rather than expanding the width of the div.
So i want to specify which child element controls the parent.
Is this possible in any way? If so, I'd love to know. Thanks in advance
"div" width problemhow to fix the width of div according to its content
Page 1 of 1
1 Replies - 1602 Views - Last Post: 05 September 2009 - 02:16 AM
Replies To: "div" width problem
#2
Re: "div" width problem
Posted 05 September 2009 - 02:16 AM
javedparamount, on 5 Sep, 2009 - 05:56 AM, said:
I am trying to set the width of a div element based on the size of an image that is within the div. I also have a text caption below the image in this same div and if the line goes longer than the width of the image than the div will be resized so that it doesn't fit so nicely around the image.
I don't want to define the width of the div because the image contained will vary in size.
I want to be able to specify that the div should only be as wide as the image and force the text to break and start new lines below rather than expanding the width of the div.
So i want to specify which child element controls the parent.
Is this possible in any way? If so, I'd love to know. Thanks in advance
I don't want to define the width of the div because the image contained will vary in size.
I want to be able to specify that the div should only be as wide as the image and force the text to break and start new lines below rather than expanding the width of the div.
So i want to specify which child element controls the parent.
Is this possible in any way? If so, I'd love to know. Thanks in advance
If you don't specify the size of the div, then it will expand to accomodate the image. If you put the text inside another div inside the biggun, or span or whatever, and set that to "width: 100%, overflow: hidden", then I would imagine it would do what you want.
<div> <img /> <span style="width: 100%, overflow: hidden">blah</span> </div>
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|