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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:14:02+00:00 2026-06-05T00:14:02+00:00

I have a parent div (main) with the horizontal overflow set to auto. I

  • 0

I have a parent div (main) with the horizontal overflow set to auto. I then have a child element (columns) that has all of my column properties on it. The problem is that once the content goes further than the viewport I can no longer control the right hand margins or padding as the column only seems to go as far as the viewport. For example when I put a background color on “columns” the background only goes as far as the edge of the viewport even though the content scrolls further than that.

.main {
    overflow-x: visible;
    overflow-y: hidden;
    width: 100%;
}
.columns {
    background: red;
    column-fill: auto;
    column-width: 670px;
    column-gap: 80px;
    height: 120px;
    padding: 20px;
    width: auto;
}

<div class="main">
     <div class="columns">
           <p></p>
           <p></p>
           <p></p>
           <p></p>
           <p></p>
     </div>
</div>

Here is an example: http://jsfiddle.net/fyG24/

  • 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-05T00:14:04+00:00Added an answer on June 5, 2026 at 12:14 am

    New Answer: Use Pseudo-Elements to Help

    Based on your comments, here is new the fiddle that I believe meets your desires. It adds an extra div wrapping .columns I labeled .scroller, and the following css:

    html {
        height: 100%;
    }
    
    body {
        margin: 0;
        padding: 0;
        height: 100%;    
    }
    .main {
        background: yellow;
        overflow: hidden;
        width: 100%;
        height: 100%;
        position: relative;
    }
    
    .main:after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        left: 0;
        height: 120px; /* match columns */
        background: red;
        z-index: 0;
    }
    
    .scroller {
        overflow-y: hidden;
        overflow-x: auto;
        height: 100%;
        position: relative;
        z-index: 1;
    }
    
    
    .columns {
        -webkit-column-fill: auto;
        -webkit-column-width: 300px;
        -webkit-column-gap: 40px;
        -moz-column-fill: auto;
        -moz-column-width: 300px;
        -moz-column-gap: 40px;
        height: 120px;
        padding: 0 20px;
        text-align: justify;
        width: auto;
    }
    
    
    .columns > p:last-of-type:after {
        content: '';
        display: block;
        width: 20px;
        height: 1px;
        float: right;
        margin-right: -20px;
        margin-top: -1px;
    }
    

    I use a pseudo-element in .main to give the background for .columns set to the explicit height you intend for those, then I also use another pseudo-element in the last p to force rendering the final 20px of the column. It should work no matter how long or what part it takes up, and at height: 1px and margin-top: -1px it should not generate a new column if it falls right at the end of a column of text.

    Original Answer: Move Overflow and Set a Right Margin

    To get the background to transfer, you need to change some CSS, namely:

    .main {
        overflow: hidden;
        width: 100%;
    }
    
    .columns {
        overflow-x: auto;
    }
    

    This seems to be because the .column background is being limited by the 100% width on the .main which is in control of the horizontal scroll bar in your original code. By making .main purely hidden, then setting overflow-x: auto on .columns, the scroll is now controlled by the .columns div, and allows its background to be seen.

    To fix the absence of padding on the far right side, the only think I could come up with was to add the following:

    .columns > p:last-of-type {
        margin-right: 20px;
    }
    

    This puts a right margin on the last p element of the immediate children of .columns which then gave the look I assume you are going for.

    Here’s the fiddle modified (tested only in Firefox).

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

Sidebar

Related Questions

I have a main parent div that is .resizable(). One of it's child divs,
If I have a parent div that is positioned absolutely and then a child
I have a parent div called main. It has a bunch of child divs
I have an unordered list that is a child in a smaller parent div
I have a parent div .photo_container that holds an img , and stretches to
If you have a parent div that wraps a fixed height div and a
I have a collection of parent div s that are labeled with unique order
I have a function that prepends a li tag to a parent div just
Hi I have the container div set for displaying horizontal and vertical scroll bar
I have a main page that has a children item. Now my question is,

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.