PDA

View Full Version : Floating content in same div more ways


CaptainB
04-27-2008, 05:56 PM
Hi,

I have wondered this for a while, actually.

Say, I have a div with two pieces of text. One of them I want aligned to the right and the other one to the left.

What is the correct way to do so? It could be archieved with eg two divs inside the container div, but I guess that isn't the correct way.

Apostropartheid
04-27-2008, 06:06 PM
What is the correct way to do so? It could be archieved with eg two divs inside the container div, but I guess that isn't the correct way.
Why wouldn't it be? You would use the container so stuff doesn't randomly go in the middle. If you want it to, that's a different matter, but...

CaptainB
04-27-2008, 06:08 PM
Someone taught me that I shouldn't use too manu divs on a page... (divitis)
But maybe it IS the way to do it?

Apostropartheid
04-27-2008, 06:20 PM
Do you mean like this?
<!doctype html>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
#content {
width: 50%;
font: .825em/1.8 'lucida sans unicode', 'lucida grande', verdana, sans-serif;
padding: 0 1em;
border: 1px #333 solid;
border-width: 0 1px;
margin: 0 auto;
}
#nav:after {
content: ".";
height: 0;
visibility: hidden;
display: block;
clear: both;
min-height: 1%;
}
* html #nav {
height: 1%;
}
#nav a {
text-decoration: none;
color: #06c;
}
#nav #prev {
float: left;
}
#nav #next {
float: right;
}
</style>
<div id="content">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc aliquam. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Duis dictum. Sed sodales tempus nunc. Donec tincidunt, velit non aliquet adipiscing, orci mauris tempor orci, quis auctor felis enim sed nulla. Etiam varius tempus arcu. Cras arcu mauris, ullamcorper sit amet, iaculis ornare, suscipit quis, risus. Pellentesque mattis augue id eros. Aliquam dui enim, molestie ac, auctor vitae, molestie nec, nisi. Curabitur commodo dui sed risus. Maecenas vitae neque a odio mattis mollis.</p>
<div id="nav">
<a href="/prev/" rel="prev" id="prev" title="Previous">&laquo; Previous</a>
<a href="/next/" rel="next" id="next" title="Next">Next &raquo;</a>
</div>
</div>

CaptainB
04-27-2008, 06:28 PM
Exactly...

Lol. I have to think before I ask. Last time I tried that method with <p> tags it didn't work. Obviousy I did something wrong, 'cause now it works.

Thanks!