html - How to make a horizontal scrolling area for left-floating element? -


i want outer <div> scroll in x-axis only, it's not working.

.wrapper {    width: 98%;    height: 320px;    padding-left:1%;    padding-right:1%;    white-space: nowrap;    overflow-y: hidden;    overflow-x: scroll;    -webkit-overflow-scrolling: touch;    background-color: #fff;    float:left;    position:absolute;  }    .internal {    width:250px;    height:320px;    display: inline;    background-color: wheat;    float:left;    position:static;  }
<div class="wrapper">      <div class="internal">item 1</div>      <div class="internal">item 2</div>      <div class="internal">item 3</div>      <div class="internal">item 4</div>      <div class="internal">item 5</div>      <div class="internal">item 6</div>      <div class="internal">item 7</div>  </div>

on screen, renders as:

screenshot showing undesired behavior

what wrong?

first, code bit of mess. have bunch of overriding rules in same selector.

you need wrap items in inner container thats set larger size wrapper. here code, cleaned up:

http://jsfiddle.net/alysdueo/

html:

<div class="wrapper">     <div class="container">         <div class="internal">item 1</div>         <div class="internal">item 2</div>         <div class="internal">item 3</div>         <div class="internal">item 4</div>         <div class="internal">item 5</div>         <div class="internal">item 6</div>         <div class="internal">item 7</div>     </div> </div> 

css:

.wrapper {     width: 98%;     height: 320px;     overflow-y: hidden;     overflow-x: scroll; } .container {     width: 1500px;     height: 320px; }  .internal {     float:left;     width:250px;     height:320px;     background-color: wheat; } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -