www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > CSS

    CSS Discussion and technical support relating to Cascading Style Sheets.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 11-04-2009, 11:56 AM
    Jo6891 Jo6891 is offline
    Registered User
     
    Join Date: May 2009
    Posts: 48
    resolved [RESOLVED] fluid css columns

    Hi there I would like to know how to create one column which would stretch horizontally to fill the space around it...

    Example: There are 3 columns. If column 1 disappears, I would like column 2 to take up the width of columns 1 and 2. If 1 and 3 disappear, I'd like column 2 to stretch the entire width.

    All 3 columns would be contained within a wrapper and should not stretch the wrapper.

    Does anyone know how this can be implemented without the need for any other script and just pure css?

    Thanks in advance.
    Reply With Quote
      #2  
    Old 11-04-2009, 12:39 PM
    kaafmim's Avatar
    kaafmim kaafmim is offline
    Registered User
     
    Join Date: Nov 2009
    Posts: 32
    You may use tables, but a table-less solution is so much better. To achieve this without any tables, you should put the removable columns inside the filling column. This is a simple html that does exactly as you want:

    Code:
    <html>
    <head>
    	<style type="text/css">
    	
    	#column1 {
    		float: left;
    		width:  30%;
    		background: #def;		
    	}
    	#column2 {
    		background: #fff;		
    	}
    	#column3 {
    		float: right;
    	
    		background: #fed;		
    		width:  30%;
    	}
    	
    	</style>
    </head>
    
    <body>
    
    	<div id="column2">
    
    		<div id="column1">This is the first column!</div>
    		<div id="column3">This is the third column!</div>
    
    		This is the second column!
    
    	</div>
    	
    </body>
    </html>

    Last edited by kaafmim; 11-04-2009 at 12:43 PM.
    Reply With Quote
      #3  
    Old 11-04-2009, 02:52 PM
    Jo6891 Jo6891 is offline
    Registered User
     
    Join Date: May 2009
    Posts: 48
    Thank you for your reply once again!

    I will give your suggestion a whirl tomorrow and see if it achieves what I need it to. I have to use a table-less solution - I would in no way dream of using tables!
    Reply With Quote
      #4  
    Old 11-05-2009, 05:08 AM
    Jo6891 Jo6891 is offline
    Registered User
     
    Join Date: May 2009
    Posts: 48
    Hi again,

    I have tried this, and it *just about* gives me the technique that I need. However, what if I need to have margins and padding between each column?

    I tried wrapping 'this is the second column!' in a div and then applying margin-right onto the first column however this didn't work. Any further suggestions?

    Thanks again
    Reply With Quote
      #5  
    Old 11-05-2009, 10:27 AM
    kaafmim's Avatar
    kaafmim kaafmim is offline
    Registered User
     
    Join Date: Nov 2009
    Posts: 32
    Code:
    <html>
    <head>
    	<style type="text/css">
    	
    	#column1 {
    		float: left;
    		width:  30%;
    		background: #def;		
    	}
    	#column2 {
    		background: #fff;		
    	}
    	#column3 {
    		float: right;
    	
    		background: #fed;		
    		width:  30%;
    	}
    	#column2_contents {
    		padding: 10px;
    		display: inline;
    	}
    	</style>
    </head>
    
    <body>
    
    	<div id="column2">
    
    		<div id="column1">This is the first column!</div>
    		<div id="column3">This is the third column!</div>
    
    		<div id="column2_contents">This is the second column!</div>
    
    	</div>
    	
    </body>
    </html>
    This works. The content div should be displayed inline.
    Reply With Quote
      #6  
    Old 11-05-2009, 12:19 PM
    Jo6891 Jo6891 is offline
    Registered User
     
    Join Date: May 2009
    Posts: 48
    Thank you once again for your reply.

    I have tried your work around, however it does not work correctly.

    I entered 3 paragraphs of lorem ipsum into the column2_contents and strange things happened - the text is not contained within that contents div and in ie not displaying correctly (looks like it's overlapping).

    Thanks for trying for me though
    Reply With Quote
      #7  
    Old 11-05-2009, 12:40 PM
    ssystems ssystems is offline
    Registered User
     
    Join Date: Oct 2009
    Posts: 232
    Check out Matthew Taylor's 3 Column. Provided you have no extra requirements that would work perfectly.

    The 'Holy Grail' 3 column Liquid Layout
    __________________
    Good Luck

    Santos Systems
    Reply With Quote
      #8  
    Old 11-09-2009, 10:36 AM
    Jo6891 Jo6891 is offline
    Registered User
     
    Join Date: May 2009
    Posts: 48
    Thank you for your reply,

    I will give that a look and let you know how I get on!
    Reply With Quote
      #9  
    Old 11-11-2009, 11:28 AM
    Jo6891 Jo6891 is offline
    Registered User
     
    Join Date: May 2009
    Posts: 48
    I have found a great tutorial which describes perfectly how to do what I'm after! If anyone else has stumbled across this thread and wants the solution:

    http://www.projectseven.com/tutorial...-flex-display/
    Reply With Quote
    Reply

    Bookmarks


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

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

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

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 07:28 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.