Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > <div question, getting fixed size of contents, not just character count

Reply
Thread Tools

<div question, getting fixed size of contents, not just character count

 
 
lhjayunaz@gmail.com
Guest
Posts: n/a
 
      08-25-2007
hi, is it possible in anyway, to read or determine absolute pixel
width size of contents within a <div> tag?

so like <div>what is pixel wXX size of this text?</div>

 
Reply With Quote
 
 
 
 
Neredbojias
Guest
Posts: n/a
 
      08-26-2007
Well bust mah britches and call me cheeky, on Sat, 25 Aug 2007 22:59:50 GMT
scribed:

> hi, is it possible in anyway, to read or determine absolute pixel
> width size of contents within a <div> tag?


-Of bare text? I think you'd need a container of some sort. Then it's
possible.

> so like <div>what is pixel wXX size of this text?</div>


Position the div absolutely.

--
Neredbojias
Half lies are worth twice as much as whole lies.
 
Reply With Quote
 
 
 
 
Jim Moe
Guest
Posts: n/a
 
      08-26-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> hi, is it possible in any way, to read or determine absolute pixel
> width size of contents within a <div> tag?
>
> so like <div>what is pixel wXX size of this text?</div>
>

For HTML, no.
It would have to be a client-side function since a div normally expands
to the width of its container. If it is floated, then it shrinkwraps the
text, probably. In either case it depends on the client's current setup:
the width of the viewport, the metrics of the font set.
What is your application that needs to know this information?

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
 
Reply With Quote
 
Martin Jay
Guest
Posts: n/a
 
      08-26-2007
On Sat, 25 Aug 2007 22:59:50 -0000, (E-Mail Removed) wrote:

>hi, is it possible in anyway, to read or determine absolute pixel
>width size of contents within a <div> tag?
>
>so like <div>what is pixel wXX size of this text?</div>


There is a discussion about this here:
<http://www.ozzu.com/ftopic39999.html>.

The fifth message in the thread may be of interest to you.

As I understand it, it's only possible to get the width of a DIV using
Javascript in IE (<7?) if it has been specifically set using CSS. In
which case you'd probably know it already.

I've uploaded a simplified page using the method described to
<http://www.spam-free.org.uk/pages/div_width.php>.

Try loading the page into Firefox, Opera or Safari and then hitting
the refresh button in the browser.

As usual IE, versions less then 7 anyway, is the odd man out.
--
Martin Jay
 
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
Cool count down timer sourcecode bug fixed ! HeroinNO.4@gmail.com Javascript 1 10-31-2006 07:27 AM
getting the character code of a character in a string Velvet ASP .Net 9 01-19-2006 09:27 PM
Free Fixed-Width/Fixed-Pitch fonts? johnp HTML 4 05-23-2005 06:14 AM
How to set the DataGrid Row Size to a fixed size. =?Utf-8?B?QmlkYXJrb3Rh?= ASP .Net 0 05-19-2005 08:14 PM
I am adding a new row to the datagrid dynamically but if i use the Count property of Item it is not showing the count of the new rows being added Praveen Balanagendra via .NET 247 ASP .Net 2 06-06-2004 07:16 AM



Advertisments