Forum Moderators: not2easy

Message Too Old, No Replies

Left and Right Aligned Text on Same Line

         

Duncan

6:07 pm on Sep 6, 2008 (gmt 0)

10+ Year Member



Hi Folks,

I'm struggling with a little problem in that I'd like to have left and right aligned text on the same line, but can't figure out how to do it. This is what I have currently and the items display on different lines.

<div class="author">John Doe (left)
<div class="pdf"><img src="img/pdf-icon.png" width="16" height="16" alt="PDF Version" /> <a href="test.pdf" title="Get the PDF Version">Get the PDF Version (right)</a></div></div>

Any help would be much appreciated.

Duncan

Marshall

6:47 pm on Sep 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Not sure haw your pdf class is defined, but if you add float: right either to it or directly in the <div class="pdf" style="float: right;">, should solve your problem. However, in the HTML, you may have to switch the order of the tow <div>. You other option is put the img at the beginning of the text in the <div> with "John Doe", and float the img right. But depending on how much text is there, it may only wrap the text, not float the img completely right.

Marshall

lavazza

7:05 pm on Sep 6, 2008 (gmt 0)

10+ Year Member



Left aligned is the default, so you (possibly/probably) only need to control the positioning of the link, using FLOAT

Oh... and control the DISPLAY of the whole section (to do this, I've declared a wrapper div, called authorAndPdfWrapper)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>edit the title</title>
<style type="text/css">
.authorAndPdfWrapper {
display:block;
clear:both;
}
.author {
background:#f00;
}
.pdf {
float:right;
background:#ff0;
}
</style>
</head>
<body>
<h1>
hello world
</h1>
<p>
Lorem ipsum dolor sit amet
</p>
<div class="authorAndPdfWrapper">
<span class="pdf">
<img src="img/pdf-icon.png" width="16" height="16" alt="PDF Version">
<a href="test.pdf" title="Get the PDF Version">
Get the PDF Version (right)</a>
</span>
<div class="author">
John Doe (left)
</div>
</div>
<p>
Nam commodo libero nec justo.
</p>
</body>
</html>

Duncan

10:33 pm on Sep 6, 2008 (gmt 0)

10+ Year Member



I've got it working now. I really appreciate the help.