tags:

views:

1926

answers:

8

See the following. How would I get the "here" and "and here" to be on the right, on the same lines as the lorem ipsums?


Lorem Ipsum etc........here
blah.......................
blah blah..................
blah.......................
lorem ipsums.......and here

A: 

the first line would consist of 3 DIVs. One outer that contains two inner divs. The first inner div would have float:left which would make sure it stays to the left, the second would have float:right, which would stick it to the right.

< div style="width:500;height:50">
< div style="float:left" >stuff < /div >
< div style="float:right" >stuff < /div >

< div > ... obviously the inline-styling isn't the best idea - but you get the point.

2,3, and 4 would be single divs

5 would work like 1.

Rob Conery
A: 

You need to put "here" into a div or span with style="float: right".

AdamB
A: 

You may be able to use absolute positioning.

The container box should be set to position: relative.

The top-right text should be set to position: absolute, top: 0, and right: 0. The bottom-right text should be set to position: absolute, bottom: 0, and right: 0.

You'll need to experiment with padding to stop the main contents of the box from running underneath the absolute positioned elements, as they exist outside the normal flow of the text contents.

ceejayoz
+3  A: 
<div style="position: relative; width: 250px;">
    <div style="position: absolute; top: 0; right: 0; width: 100px; text-align:right;">
        here
    </div>
    <div style="position: absolute; bottom: 0; right: 0; width: 100px; text-align:right;">
        and here
    </div>
    Lorem Ipsum etc <br />
    blah <br />
    blah blah <br />
    blah <br />
    lorem ipsums
</div>

Gets you pretty close, may need to tweak the "top" and "bottom" values.

Garry Shutler
A: 
<style>
  #content { width: 300px; height: 300px; border: 1px solid black; position: relative; }
  .topright { position: absolute; top: 5px; right: 5px; text-align: right; }
  .bottomright { position: absolute; bottom: 5px; right: 5px; text-align: right; }
</style>
<div id="content">
  <div class="topright">here</div>
  <div class="bottomright">and here</div>
  Lorem ipsum etc................
</div>
Loren Segal
A: 

If the position of the element containing the Lorum Ipsum is set absolute, you can specify the position via CSS. The "here" and "and here" elements would need to be contained in a block level element. I'll use markup like this.

print("<div id="lipsum">");
print("<div id="here">");
print("  here");
print("</div>");
print("<div id="andhere">");
print("and here");
print("</div>");
print("blah");
print("</div>");

Here's the CSS for above.

#lipsum {position:absolute;top:0;left:0;} /* example */
#here {position:absolute;top:0;right:0;}
#andhere {position:absolute;bottom:0;right:0;}

Again, the above only works (reliably) if #lipsum is positioned via absolute.

If not, you'll need to use the float property.

#here, #andhere {float:right;}

You'll also need to put your markup in the appropriate place. For better presentation, your two divs will probably need some padding and margins so that the text doesn't all run together.

BrewinBombers
A: 

Or even better, use HTML elements that fit your need. It's cleaner, and produces leaner markup. Example:

<dl>
   <dt>Lorem Ipsum etc <em>here</em></dt>
   <dd>blah</dd>
   <dd>blah blah</dd>
   <dd>blah</dd>
   <dt>lorem ipsums <em>and here</em></dt>
</dl>

Float the em to the right (with display: block), or set it to position: absolute with its parent as position: relative.

Bruce
A: 

Float right the text you want to appear on the right, and in the markup make sure that this text and its surrounding span occurs before the text that should be on the left. If it doesn't occur first, you may have problems with the floated text appearing on a different line.

<html>
  <body>
    <div>
      <span style="float:right">here</span>Lorem Ipsum etc<br/>
      blah<br/>
      blah blah<br/>
      blah<br/>
      <span style="float:right">and here</span>lorem ipsums<br/>
    </div>
  </body>
</html>

Note that this works for any line, not just the top and bottom corners.

phloopy
But the "and here" appears on a new line, instead of the same line as the final "blah"
Corey Trager
In which browser? It worked fine for me in the major three, as long as you have the floated text first.Absolute positioning will certainly work if you only care about the corners of the box, but this allows you to float text on arbitrary lines all the way to the right.
phloopy