![]() |
|
||||||||||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|||||
|
|
#1 |
|
WLC Member
Join Date: Sep 2006
Posts: 9
|
Exactly how is it done with CSS? I hate Tables, but can't figure out how to make columns with DIVs. They always end up one above the other, never side by side.
|
|
|
|
|
#2 |
|
WLC Lover
Join Date: Apr 2006
Location: Falköping, Sweden
Posts: 106
|
Hi!
Something like this should solve your problem. Code:
div { width: 300px; border: 1px solid red; float: left}
Code:
<div>Woho, first div!</div> <div>And a second one!</div>
__________________
To view links or images in signatures your post count must be 5 or greater. You currently have 0 posts. |
|
|
|
|
#3 |
|
WLC Member
Join Date: Sep 2006
Posts: 9
|
Hmm, but what if I want one div on left and one on right, but on the same vertical level? Plus float seems to make the divs come out of any container div i might use.
|
|
|
|
|
#4 |
|
WLC Member
Join Date: Sep 2006
Posts: 8
|
Hi,
To get one column to go to the left and one to the right you could do this: CSS Code:
#leftcolumn { width: 300px; border: 1px solid red; float: left}
#rightcolumn { width: 300px; border: 1px solid red; float: right}
Code:
<div id="leftcolumn"><p>text goes here</p></div> <div id="rightcolumn"><p>text goes here</p></div> Like this: CSS Code:
.clear { clear: both;}
Code:
<div id"container"> <div id="leftcolumn"><p>text goes here</p></div> <div id="rightcolumn"><p>text goes here</p></div> <div class"clear"></div> </div> |
|
|
|
|
#5 |
|
WLC Lover
Join Date: Jul 2006
Location: United Kingdom, Hertfordshire
Posts: 266
|
Easy really. Or you can use a margin on the second div and give it a float left to give it a specific distance apart from the 1st.
__________________
** To view links or images in signatures your post count must be 5 or greater. You currently have 0 posts. ** Simple articles to help anyone get started. |
|
|
|
|
#6 |
|
WLC Member
Join Date: Sep 2006
Posts: 9
|
Thanks DaveST. I will try it. Is { clear: both;} meant to be used for that reason or is it a hack that just works for some unknown reason?
__________________
To view links or images in signatures your post count must be 5 or greater. You currently have 0 posts. |
|
|
|
|
#7 | |
|
WLC Member
Join Date: Sep 2006
Posts: 9
|
Quote:
__________________
To view links or images in signatures your post count must be 5 or greater. You currently have 0 posts. |
|
|
|
|
|
#8 |
|
WLC Member
Join Date: Sep 2006
Posts: 8
|
{clear: both;} is not a hack, it's legitimate CSS, just not very pretty. You'll probably get the same effect if you can add the clear attribute to an element that succeeds the two columns (if it of course is also nested in the container div), for example a footer.
To understand clear I like to think of it as if your telling an element to clear away everything from it's left, right or in this case both it's left and right. This has the effect of dropping the element below the two columns and taking the container div with it. Just to clarify, there are 3 values you can asssign to clear (left, right and both). I hope this helps. |
|
|
|
|
#9 |
|
WLC Member
Join Date: Jul 2006
Location: l.a!
Posts: 25
|
to get a div left and one right, you would still use float: left; on both....
and like previously mentioned, use margins to seperate the divs. http://cssguide.scudworkz.com/floats_clears/
|
|
|
|
|
#10 |
|
WLC Member
Join Date: Sep 2006
Posts: 9
|
Thanks Dave, that explains a lot!
Coolaid, thanks for that link, seems like exactly what I needed to learn.
__________________
To view links or images in signatures your post count must be 5 or greater. You currently have 0 posts. |
|
|
![]() |
| Thread Tools | |
| Display Modes | |
Linear Mode |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Divs in a grid | netfuel | HTML & XHTML | 4 | 28th June 07 12:05 PM |
| IE side by side div float | akashenk | Browser Compatibility | 3 | 14th January 07 01:41 PM |
| extending multiple divs to fill the screen | gucci09 | Scripting and Server Side | 1 | 10th January 07 05:54 PM |
| Strange problem with nested div's in IE | emjay1 | Browser Compatibility | 2 | 1st September 06 04:28 PM |