TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-05-2008, 08:30 AM   #1 (permalink)
The Frequenter
 
Join Date: Dec 2007
Location: In my basement
Posts: 386
Thanks: 47
Aaron is on a distinguished road
Default two columns?

How do I make two columns (not a two column layout, just two columns)?

I tried like... everything, and It won't work without tables. If you add info on the left it pushes the right part down..
Send a message via MSN to Aaron
Aaron is offline  
Reply With Quote
Old 01-07-2008, 02:56 AM   #2 (permalink)
The Wanderer
 
hostfreak's Avatar
 
Join Date: Oct 2007
Posts: 21
Thanks: 1
hostfreak is on a distinguished road
Default

Your going to want to look into the CSS Float property: CSS Float Property
hostfreak is offline  
Reply With Quote
Old 01-07-2008, 03:22 AM   #3 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

As hostfreak says, use the float property. Here's a simple mock-up:

html4strict Code:
<html>
<head>

    <style type="text/css">

        div.left
        {
            float: left;
            overflow: hidden;
            border: 1px solid red;
            width: 100px;
            height: 200px;
        }
        div.right
        {
            float: left;
            overflow: hidden;
            border: 1px solid blue;
            width: 100px;
            height: 200px;
            margin-left: 2px;
        }

    </style>

</head>
<body>

    <div class="left">Left Column</div>
    <div class="right">Right Column</div>

</body>
</html>
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 01-07-2008, 03:41 AM   #4 (permalink)
The Acquainted
 
Join Date: Sep 2007
Location: Arizona
Posts: 114
Thanks: 10
Andrew is on a distinguished road
Default

I would also suggest putting this:
Code:
* {
    margin: 0;
    padding: 0;
}
at the top of your CSS file to reset all paddings and margins. This way, you won't have as much trouble with the IE box model if you need to fit the two columns within a certain width container.
Send a message via AIM to Andrew Send a message via MSN to Andrew
Andrew is offline  
Reply With Quote
Old 01-08-2008, 01:11 PM   #5 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Yea. Well pointed out, Andrew. I always add that at the top and it really does save a lot of the time. It's predominantly due to that Firefox, IE, Opera, et cetera... all stupidly set their very own margin and padding for various elements, and thus resetting all the values allows you to build from the ground up.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 01-10-2008, 11:59 AM   #6 (permalink)
The Frequenter
 
Join Date: Dec 2007
Location: In my basement
Posts: 386
Thanks: 47
Aaron is on a distinguished road
Default

I have a reset.css file that resets EVERYTHING to a shared medium. This also helps guard against people toying with default values >.>

Anyway.. How does that work if it is both float:left; ?
Send a message via MSN to Aaron
Aaron is offline  
Reply With Quote
Old 01-15-2008, 09:21 AM   #7 (permalink)
The Contributor
 
Join Date: Apr 2005
Location: Kent, UK
Posts: 54
Thanks: 0
Dr John is on a distinguished road
Default

If the sum of the divs widths is less than the full width of the space available they both float to the left and bump into each other, so to speak, and end up sitting next to each other. If you don't float them both, one drops below the other. Dropping below the other can also happen if you add borders and margins and padding and the sum of their total width exceeds the total space available. you can also get this if you use percentages as widths and rounding off errors take you over the 100% mark, so I often make the percentages add up to 95% instead.
__________________
www.kidneydialysis.org.uk
Dr John is offline  
Reply With Quote
Old 01-15-2008, 06:19 PM   #8 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

A clear is always required after floating elements. Otherwise, you risk your sanity because everything flows around:

html4strict Code:
<html>
<head>

    <style type="text/css">

        div.left
        {
            float: left;
            overflow: hidden;
            border: 1px solid red;
            width: 100px;
            height: 200px;
        }
        div.right
        {
            float: left;
            overflow: hidden;
            border: 1px solid blue;
            width: 100px;
            height: 200px;
            margin-left: 2px;
        }
        .clear { clear:both; float:none;}
    </style>

</head>
<body>

    <div class="left">Left Column</div>
    <div class="right">Right Column</div>
    <div class="clear"></div>
</body>
</html>
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 11:15 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design