0

Here is my code

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style type="text/css">
#image_container
{
    position:absolute;
    top:100px;
    left:0px;
    height:420px;
}
.folder_image
{
    background:url(folder.png) top no-repeat;
    width:679px;
    height:420px;
    top:0px;
    left:0px;
    position:relative;
    float:left;
    margin-right:50px;  
}
</style>
</head>

<body>
<div id="overflow_container">
    <div id="image_container">
        <div class="folder_image"></div>
        <div class="folder_image"></div>
    </div>
</div>
</body>
</html>

This is what I am trying to achieve : As and when I add new divs with the class folder_image , the divs should sit one next to each other horizontally. I know that this can be done by setting the width of the parent container , #image_container in my case , but how do I do it without setting the width of #image_container

Thanks in advance.

Harsha Venkataramu
  • 2,887
  • 1
  • 34
  • 58

3 Answers3

1

try this

.folder_image
{
    background:url(folder.png) top no-repeat #030;
/*    width:679px;*/
    height:420px;
/*  top:0px;
    left:0px;
    position:relative;
    float:left;*/
    margin-right:50px;  
    display:inline-block;
}

jsFiddle File

Roy Sonasish
  • 4,571
  • 20
  • 31
1

Use float:left; to .folder_image

DEMO http://jsfiddle.net/yeyene/YnUGb/1/

.folder_image
{
    background:url(folder.png) top no-repeat;
    width:200px;
    height:200px;
    float:left;
    margin:20px;  
}
yeyene
  • 7,297
  • 1
  • 21
  • 29
1

My solution :

#image_container
{
    position:absolute;
    top:100px;
    left:0px;
    height:420px;
    overflow-x: scroll;
    overflow-y: none;
    white-space:nowrap;
}
.folder_image
{
    background:red;
    width:679px;
    height:420px;
    display: inline-block;
    margin-right:50px;  
}

Fiddle: http://jsfiddle.net/eKW46/

This post helped me : CSS horizontal scroll

Community
  • 1
  • 1
Augustin Riedinger
  • 20,909
  • 29
  • 133
  • 206