473,394 Members | 1,567 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,394 software developers and data experts.

Floating text on wrapped line

Sorry if this goes through twice, I had an error the first time that I
submitted.

I have a bit of text that has a varying length, and I'm wanting to
float text to the right. The problem is that the text needs to wrap to
2 lines instead of 1, and I'm wanting to float the text to the right
of the second line.

Something like this:

blah blah blah blah blah blah blah blah blah
blah blah blah... floated text

(If that doesn't show up correctly, I have 23 whitespaces between
"..." and "floated text")

I'm chopping the text at 75 characters and adding the ... myself, so I
know that the total length of blah blah will be 75 characters or less.
But I have no way of knowing if the top line will be 40 characters, 45
characters, or what, before it wraps.

I originally thought that this would work:

<div style="float: left: width: 80%">blah blah...</div>
<div style="float: right: width: 20%">floated text</div>

But this makes the top line wrap at 80%, too, where I only want the
second line to be 80%. I want the floated text to be aligned directly
beneath the last word of the first line.

The only solution I can think of is to go to the 50th character, then
go back to the last whitespace and chop from there, so that there
would be a variable on line 1 and a separate variable on line 2.
Something like:

$var1 = "blah blah blah blah blah blah blah blah blah";
$var2 = "blah blah blah...";

$var1
<div style="float: left: width: 80%">$var2</div>
<div style="float: right: width: 20%">floated text</div>

This should float correctly, but is there an easier way?

TIA,

Jason
Oct 31 '08 #1
2 2204
On 2008-10-31, Jason Carlton <jw*******@gmail.comwrote:
Sorry if this goes through twice, I had an error the first time that I
submitted.

I have a bit of text that has a varying length, and I'm wanting to
float text to the right. The problem is that the text needs to wrap to
2 lines instead of 1, and I'm wanting to float the text to the right
of the second line.

Something like this:

blah blah blah blah blah blah blah blah blah
blah blah blah... floated text

(If that doesn't show up correctly, I have 23 whitespaces between
"..." and "floated text")

I'm chopping the text at 75 characters and adding the ... myself, so I
know that the total length of blah blah will be 75 characters or less.
But I have no way of knowing if the top line will be 40 characters, 45
characters, or what, before it wraps.

I originally thought that this would work:

<div style="float: left: width: 80%">blah blah...</div>
<div style="float: right: width: 20%">floated text</div>

But this makes the top line wrap at 80%, too, where I only want the
second line to be 80%. I want the floated text to be aligned directly
beneath the last word of the first line.
This last requirement limits your options, assuming you want the last
word of the first line to follow the words before it with the normal
amount of spacing.

You will have to position the right floated text relative to that last
word probably using absolute positioning. But I'm not convinced that's
what you want based on your solution below:
The only solution I can think of is to go to the 50th character, then
go back to the last whitespace and chop from there, so that there
would be a variable on line 1 and a separate variable on line 2.
Something like:

$var1 = "blah blah blah blah blah blah blah blah blah";
$var2 = "blah blah blah...";

$var1
<div style="float: left: width: 80%">$var2</div>
<div style="float: right: width: 20%">floated text</div>

This should float correctly, but is there an easier way?
That won't put "floated text" directly beneath the last word on the
first line.

If you're going to do that, you could just put all the text in a single
block, and then at the 50th character insert:

<br><span style="float: right; width: 20%">floated text</span>.

Leave out the <brif you're not too particular about exactly where that
first line breaks.
Oct 31 '08 #2
In article
<6c**********************************@o40g2000prn. googlegroups.com>,
Jason Carlton <jw*******@gmail.comwrote:
Sorry if this goes through twice, I had an error the first time that I
submitted.

I have a bit of text that has a varying length, and I'm wanting to
float text to the right. The problem is that the text needs to wrap to
2 lines instead of 1, and I'm wanting to float the text to the right
of the second line.

Something like this:

blah blah blah blah blah blah blah blah blah
blah blah blah... floated text
A URL of your best shot would have been good. (...another $US2.20 for me)

Is this what you want:

<http://dorayme.890m.com/alt/blahblah.html>

--
dorayme
Oct 31 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Danny F | last post by:
Is it possible to have line feeds/breaks automatically entered when the text wraps to a new line? I am using a <textarea> input on a form and using the <pre> tag when displaying the text to a html...
3
by: Andrew Fedoniouk | last post by:
<CITE src="http://www.w3.org/TR/html401/present/graphics.html#h-15.1.3"> 15.1.3 Floating objects Images and objects may appear directly "in-line" or may be floated to one side of the page,...
3
by: JHR | last post by:
Hey all, I'm trying to make a sidebar box float to the right of various items, and for those items to wrap if a user shrinks his browser window. Instead, in every browser I've tried except for...
3
by: Oliver Bryant | last post by:
I just finished developing a javascipt component allowing floating captions to appear over HTML elements. If anyone wants to check it out you can see specs and download it from...
2
by: Sam Martin | last post by:
Hi all, I want to be able to draw wrapped text started at a point x into the rectangle on the first line If there's not a GDI+ method for this, i'm guessing it's a common technique, but can't...
6
by: TomB | last post by:
Hello all, On the page located at http://deimos.curious.be/~dusk/lyrics.php#gotn I have put the lyrics text inside <pre> elements so that the UA renders the linebreaks in the code. Because...
2
by: jawilson | last post by:
Hello, I am working on a project in Borland Developer Studio 2006, and am running into an error I don't understand. Here is the relevant code: ...
7
by: thisismyidentity | last post by:
Hi all, I am trying to predict the behaviour of floating point load and store operations on integer locations. I ve written a small piece of code having some inline assembly code which I am...
0
by: Jason Carlton | last post by:
I have a bit of text that has a varying length, and I'm wanting to float text to the right. The problem is that the text needs to wrap to 2 lines instead of 1, and I'm wanting to float the text to...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.