Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to have some div's side by side in a horizontal row. I want the container to only show part of the row at a time with scrolling. Currently, the div's are just in 1 column. Maybe I'm crazy, can't see why this won't work. Thanks!

See this JSFiddle: http://jsfiddle.net/42kurwtp/

HTML

    <div style="width: 300px; height: 300px; overflow:scroll;">
        <div id="blue"></div>
        <div id="red"></div>
        <div id="green"></div>
        <div id="yellow"></div>
    </div>

CSS

<style>
div {
    width: 200px;
    height: 200px;
    float: left;
}
    #blue {
        background: blue;
    }

    #red {
        background: red;
    }

    #green {
        background: green;

    }

    #yellow {
        background: yellow;
    }
</style>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
127 views
Welcome To Ask or Share your Answers For Others

1 Answer

<style> #row {
  overflow: scroll;
  width: 900px;
  height: 70px;
}
#row div {
  width: 200px;
  height: 200px;
  float: left;
}
#blue {
  background: blue;
}
#red {
  background: red;
}
#green {
  background: green;
}
#yellow {
  background: yellow;
}
</style>
<div class="row" id="row">
  <div id="blue">&nbsp;</div>
  <div id="red">&nbsp;</div>
  <div id="green">&nbsp;</div>
  <div id="yellow">&nbsp;</div>
</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...