Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > div box questions; float text around a box, fit box to image size

Reply
Thread Tools

div box questions; float text around a box, fit box to image size

 
 
Gnarlodious
Guest
Posts: n/a
 
      09-15-2005
Is there a way to "float" text around a div box the way it can float around
an image?

Also, trying to get away from tables. I want to put a caption under an image
inside the aforementioned div box ,
Is there a way to make a box around the image say, with 1em of margin larger
than the image? Or do I need to force the box to explicitly be a certain
size? As it is, a div box is unable to know how large an image is.

Thanks for any clues.

-- Gnarlie

 
Reply With Quote
 
 
 
 
Els
Guest
Posts: n/a
 
      09-15-2005
Gnarlodious wrote:

> Is there a way to "float" text around a div box the way it can float around
> an image?


yes, and it works exactly the same way. Give the div box a width and
float it like you would an image.

> Also, trying to get away from tables. I want to put a caption under an image
> inside the aforementioned div box ,
> Is there a way to make a box around the image say, with 1em of margin larger
> than the image? Or do I need to force the box to explicitly be a certain
> size? As it is, a div box is unable to know how large an image is.


True. But why would you need to have a 1em margin on the image? If it
is to keep the text away from it, set the width of the div to be the
same as the width of the image, and set the margin on the div. (on
left floated, only a right margin is needed, on right floated, a left
margin).
The added advantage of that, is that if you add a caption below the
image inside the floated div, it will not make the div go wider, but
rather wrap the caption if it were a longer sentence.

> Thanks for any clues.


You're welcome

--
Els http://locusoptimus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Now playing: Chuck Berry - No Particular Place To Go
 
Reply With Quote
 
 
 
 
Gnarlodious
Guest
Posts: n/a
 
      09-15-2005
Entity Els spoke thus:

>> Is there a way to "float" text around a div box the way it can float around
>> an image?

>
> yes, and it works exactly the same way. Give the div box a width and
> float it like you would an image.

Yes! It is working, however it appears there is no inline width declaration
for div boxes. Since all my images are of varying width, what's the easiest
way to do this? Oddly, a div box knows how high an image is but not how
wide!

-- Gnarlie
http://Gnarlodious.com/Cogent/

 
Reply With Quote
 
Els
Guest
Posts: n/a
 
      09-15-2005
Gnarlodious wrote:

> Entity Els spoke thus:
>
>>> Is there a way to "float" text around a div box the way it can float around
>>> an image?

>>
>> yes, and it works exactly the same way. Give the div box a width and
>> float it like you would an image.

>
> Yes! It is working, however it appears there is no inline width declaration
> for div boxes. Since all my images are of varying width, what's the easiest
> way to do this?


Server side. Pick up the width/height of the image with php or another
server side scripting language, and take that width to go in the width
setting for the div. Obviously, you'd set the width for each div in an
inline style then, not in the stylesheet.

Without server side scripting it would just have to be coded by hand.

> Oddly, a div box knows how high an image is but not how wide!


If you'd float the div without setting a width, it actually would
'shrink-wrap' around the image. It's the caption that may cause it to
stretch wider than the image.

It doesn't necessarily know the height of the image, but it just
closes at the end of the content. Which is good, otherwise you could
never have flexible text-flow or font-size inside a div without
serious problems

--
Els http://locusoptimus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Now playing: Smokie - Wild Angels
 
Reply With Quote
 
elizas elizas is offline
Junior Member
Join Date: Jan 2010
Location: India
Posts: 29
 
      05-05-2010
Commonly we use textbox & textarea to write text by keyboard.But there is another control which can be used for the same pupose. Its DIV.

Generally Div is used as container of other control or to show readonly text by setting the following property of div:

contentEditable = "true"
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
float to string to float, with first float == second float Carsten Fuchs C++ 45 10-08-2009 09:47 AM
Image does not fit correctly in a div frame AAaron123 ASP .Net 8 07-13-2009 10:31 AM
Make wxListCtrl fit around contents and parent frame fit around listctrl Piet Python 0 07-18-2004 08:27 AM
size a DIV as large as needed to fit contents JezB ASP .Net 14 07-07-2004 12:38 PM
Re: float->byte->float is same with original float image. why float->ubyte->float is different??? bd C Programming 0 07-07-2003 12:09 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57