Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7046261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:37:45+00:00 2026-05-28T02:37:45+00:00

I need some help in building a flexible html layout. I’ve defined minimum and

  • 0

I need some help in building a flexible html layout. I’ve defined minimum and maximum width of the page wrap. Inside the wrap, I have two columns, content and right.

I want to have fixed width right column. But, I want to make the content width flexible, so that depending on min-width and max-width, its width should increase or decrease.

Here’s my html structure:

<body>
    <div class="wrap">
        <div class="content">...</div>
        <div class="right">...</div>
    </div>
</body>

Here’s CSS, I’m trying:

.wrap{
    min-width: 780px;
    max-width: 1140px;
    margin: 10px auto;
}

.right{
    float:left
    width: 200px;   
}

.content{
    float: left;
    width: ?? //what should i do here?

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:37:46+00:00Added an answer on May 28, 2026 at 2:37 am

    When making floated columns in CSS there’s a few things to learn.

    First, the container (in your case .wrap) should also be cleared for floats. Here’s a good Stackoverflow question on “clearfix”. “Clearfix-ing” will ensure that the container height will stretch to match the longest floated column. Useful for doing the “faux columns” design.

    What methods of ‘clearfix’ can I use?

    Second, is the need to know how many columns are you looking to do? 2 columns? 3 Columns?

    There are different ways to skin that cat. You can do 2 columns and then sub-divide one of those columns by another 2 column layout. Or you can put 3 block containers and float each of them to a percentage of the total width. Ie. for a 3 column layout you’d theoretically want each to be 33.33% wide (depending on how you want to do gutters or margins).

    Third, you talk about “flexible layout”. Well, a flexible layout can’t work with pixel width as pixels are static values. Ie. If you say the width is 200px, it’s always 200px, no matter how big or small your container or window is.

    What you need to do is use percentages. Of course, to do a correct flexible layout you want to have a base dimension. So, you do need to have a fixed with design that you will say is your “optimal design” (I have to use that term loosely as a true flexible and responsive design should look good for the most part).

    So, lets say your design is set to have the main content area .wrap be 1000px. You want a 2 column layout using the golden ratio. http://en.wikipedia.org/wiki/Golden_ratio

    Basically, you want one column to be 618px and the other to be 1000px – 618px = 382px.

    For CSS you then want to set them in terms of percentages. To get the percentage you take the parent width and divide it by the width you want.

    618px / 1000px = .618 * 100(for percentage) = 61.8%

    382px / 1000px = .382 * 100(for percentage) = 38.2%

    .left {
        float: left;
        width: 61.8%
    }
    
    .right {
        float: right;
        width: 38.2%
    }
    

    Joseph Silber is correct, you don’t need to float the right column, but not doing so can cause other unexpected issues of how the box model acts and wraps around the floated left item, especially if one is shorter than the other.

    You can apply a margin to offset one column to another columns width, but I find that to just be messy and there could still be problems with poor CSS implementations in browsers (as much as I say I don’t support IE6 anymore, it’s still used by our visitors enough to need to support it).

    Also note, when dealing with % is that you run into rounding errors. Some browsers will round down or up when they hit “.5%”. This can cause your floated columns to wrap because it becomes 1px larger than the container element. So, to be safe, you will want to probably shave off a little bit of the width to give you a 1-2px buffer for wrapping.

    A common approach is to give an “empty” gutter or margin between the left and right column of say 10px. And 10px in our design is:

    10px / 1000px = 0.01 * 100(for percentage) = 1%

    You can now take 0.5% off each column or take a full 1% off one column. I’ll just do the later.

    .left {
        float: left;
        width: 60.8% /* removed 1% to give a gutter between columns */
    }
    
    .right {
        float: right;
        width: 38.2%
    }
    

    This now gives you a nice safety zone and you will avoid rounding errors.

    Also, now that we’re working in %, the layout will be fluid. Your 2 columns will re-size with your browser until you hit the min/max pixel value.

    Also, don’t forget to “clearfix”

    <div class="wrap clearfix">
    
        <div class="left">
            <!-- content -->
        </div>
    
        <div class="right">
            <!-- content -->
        </div>
    
    </div>
    

    There are, of course, a lot of other considerations to take into account when dealing with fluid/flexible grids.

    One thing you can do is not re-create the wheel but use a CSS framework like Yahoo! or Blueprint. I believe they have these built-in and have been robustly tested.

    Also, I recommend reading up on Responsive Web Design. There’s an A List Apart article on it: http://www.alistapart.com/articles/responsive-web-design/ as well as a book written by Ethan Marcotte (the other of the article and published by the ALA website) that is a great read.

    The only real drawback about the book is that it didn’t cover the drawbacks of a Responsive design and how, despite the “cool” factor, many big name web designers/developers have chosen to still use a separate mobile/desktop website design.

    Which is slight off-topic as the original question was only talking about a fluid design and not a media target size.

    Hope that helps!

    Cheers!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need some help to solve this. I have a gridview and inside the gridview
Need some help from javascript gurus. I have one page where http://www.google.com/finance/converter is embedded
I need some help building an Query. I have a table Orders with 3
Hey. I urgently need some help on building up a complete table using VBA.
I need your help building a SQL statement I can't wrap my head around.
I am building a project management app and need some help with how to
I need some help on what's important and best practices when building a .NET
I am new to WPF and need some help and guidance. I am building
I need some help,showing a map inside my rails 3.0 pages I fond cartographer
I need some help building a table(s) for a music database in MySQL. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.