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

  • Home
  • SEARCH
  • 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 6607099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:27:59+00:00 2026-05-25T19:27:59+00:00

Say I have two divs A and B, which are currently aligned side by

  • 0

Say I have two divs A and B, which are currently aligned side by side. How can I get A to be separated from B by 50px, while still letting A to take up 70% of the remaining space and B the remaining 30%?

EDIT: Accepted the answer a little early before I actually tried. Whoops.

JSFiddles:

A Tale of Two Divs

Now separated, but now with the second one on a second line?

  • 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-25T19:28:00+00:00Added an answer on May 25, 2026 at 7:28 pm

    I believe your selected answer will not work:

    http://jsfiddle.net/cNsXh/

    edit:
    Sorry, the above example was not correct at first. Now it is.
    /edit

    As you can see, div #b will move under div #a because margin-left (or padding-left) will be added to the 30%. And because we’re mixing percentage with pixel values here, we will not be able to define values that will guarantee to always add up to exactly 100%.

    You’ll need to use a wrapper for div #b which will have 30% width, and not define a width for div #b, but define margin-left. Because a div is a block element it will automatically fill the remaining space inside the wrapper div:

    http://jsfiddle.net/k7LRz/

    This way you will circumvent the CSS < 3 box-model features which oddly enough was defined such that defining a dimension (width / height) will NOT subtract margins and/or paddings and/or border-width.
    I believe CSS 3’s box-model will provide more flexible options here. But, admittedly, I’m not sure yet about cross-browser support for these new features.

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

Sidebar

Related Questions

Lets say I have two divs How do I use .find to get div1's
Say you have two binary values 001011 001111 How can you get the number
I have been having this problem in IE. I have two divs which I
Say I have two tables, users and groups each of which has an auto-incrementing
Say I have two programs X and Y asking for input from stdin .
I have a somewhat grouping system which all the elements between two divs are
Say I have two lists: >>> l1=[1,2,3,4] >>> l2=[11,12,13,14] I can put those lists
say i have these two uniquely ID'd divs with input elements that are not
Say I have two classes which extend Event : public class CustomEventOne extends Event
Let's say I have a bunch of divs which have either left class or

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.