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 8803827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:26:34+00:00 2026-06-14T01:26:34+00:00

I’m working on a layout that includes two adjacent fluid-width divs (each width: 50%)

  • 0

I’m working on a layout that includes two adjacent fluid-width divs (each width: 50%) inside one container that is 80% of the body width.

I’d like to have a 10px margin between the left and right 50% divs, but I need the whole assembly to fit within the 80% body width container. I understand that reducing the % width of the left and right DIVs will work to give me room for the 10px center margin, but it would also mean the whole left DIV/right DIV/10px margin assembly would often not be 80% of the body width.

Is there a way to recalculate the width of the left and right DIVs so they cumulatively occupy 80% of the body width when there is a fixed 10px margin in between them, no matter what the browser window is resized to? Not sure if this is doable with CSS. If Javascript is the only way to achieve it that’s fine, but it would be great if there’s some hidden CSS trick I’m missing.

Here’s my CSS:

#logoplace {
width: 200px;
height: 200px;
background-color: red;
margin-left: auto;
margin-right: auto;
}

#navcontainer {
height: 30px;
width: 80%;
background-color: white;
margin: 5px auto;
opacity: 0.7;
}

#navcontainer:hover {
opacity: 1;
}

#rowone {
width: 80%;
height: 120px;
background-color: white;
margin: 5px auto;
}

#rowoneone {
width: 50%;
height: 120px;
background-color: green;
margin-right: 5px;
float: left;
}

#rowonetwo {
width: 50%;
height: 120px;
background-color: blue;
margin-left: 5px;
float: right;
}

html, body
{
height: 100%;
padding-left: 20px;
padding-right: 20px;
padding-top: 20px;
padding-bottom: 20px;
}

And my HTML:

<div id="logoplace">
</div>
<div id="navcontainer">
</div>
<div id="rowone">
    <div id="rowoneone">
    </div>
    <div id="rowonetwo">
    </div>
</div>

Finally here’s a JsFiddle that shows the result I’m getting. The right-floated DIV is getting pushed down, obviously because I’ve set both floated DIVs to 50% and then added the fixed margin.

Any help is greatly appreciated!

  • 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-06-14T01:26:36+00:00Added an answer on June 14, 2026 at 1:26 am

    http://jsfiddle.net/thirtydot/KX6eR/30/

    Add an extra wrapper:

    <div id="rowone">
        <div id="rowonewrapper">
            <div id="rowoneone"></div>
            <div id="rowonetwo"></div>
        </div>
    </div>
    

    ​
    Then reposition your two inner divs slightly:

    #rowonewrapper {
        margin-right: 10px;
    }
    #rowoneone {
        width: 50%;
        height: 120px;
        background-color: green;
        float: left;
    }
    
    #rowonetwo {
        width: 50%;
        height: 120px;
        background-color: blue;
        float: right;
        position: relative;
        left: 10px;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I've tracked down a weird MySQL problem to the two different ways I was
I know there's a lot of other questions out there that deal with this

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.