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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:07:34+00:00 2026-06-12T08:07:34+00:00

Lets say I have this <div class=sectionContainer> <div class=itemsContainer> <div class=items></div> <div class=items></div> <div

  • 0

Lets say I have this

<div class="sectionContainer">
    <div class="itemsContainer">
        <div class="items"></div>
        <div class="items"></div>
        <div class="items"></div>
    </div>
</div>

The css:

.itemsContainer 
{
 /* width:3000px works, however this is what I want to avoid saying explicitly.*/
}

.sectionContainer
{
width: 1000px;
overflow: auto; 
}

.items
{
width: 1000px;     
float: left;     
}

The sectionContainer has some set width.

The items has some set width.

The items container does not have a set width; it will scale to the size of its contents.
The items container’s overflow is set to hidden, so that one can scroll through the items within the div. The items within the div are horizontally displayed IE they are side-by-side, I’m currently doing this with a float.

How can I do this with CSS only? Is it possible? I’m not looking for a JavaScript solution right away but can resort to that if needed.

to be more specific, this would work if I specified the itemsContainer to have a width of 3000. But I’m guessing that since it is the child of its parent div, its width gets sized to 1000. I do not want to explicitly set the size of the itemsContainer because this should be based upon the number of items. If I add more items, I want the itemsContainer to change its width to contain all of those items without having to alter the CSS.

Thanks!

  • 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-12T08:07:36+00:00Added an answer on June 12, 2026 at 8:07 am

    It’s not possible for CSS to guess what you want to happen — meaning that it wants to cascade elements downward as opposed to horizontally, which is what you want.

    http://jsfiddle.net/9NHFa/

    Set the itemsContainer width to a 100% X the number of elements.

    .itemsContainer 
    {
    width:300%; /* since you have 3 elements
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, lets say that we have this structure: <div id='allTempLinkHolder'> <div class='tempLink'>Value</div> <div class='tempLink'>Value
Lets say we have this code: <div id='m1'> <div class=c></div> <div class=c></div> <div class=c></div>
Lets say that I have a HTML that looks like this: <div class=aaa><span>1</span></div> <div
Lets say I have this code: <div class=user> <img class=profilepic src=someimage.jps> <div class=cleaner></div> [
Lets say I have this kind of set of images: <div class=image><img src=image1.jpg alt=
Lets say I have CSS like this: div.form label input { /* some css
Say I have something like this: <a href=/ad.php?go=123> <div class=ad></div> </a> Lets say the
Let's say I have this: <div id=wrapper> <pre class=highlight> $(function(){ // hide all links
Let's say I have a list like this: <ul class=list> <li><span class=pos><div class=txt_pos>1</div></li> <li><span
Lets say have this immutable record type: public class Record { public Record(int x,

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.