Reputation: 8998
I have a ul list which is inside a bootstrap grid element:
<div class="row">
<div class="col-sm-8">
<div id="playlist-wrapper">
<ul id="playlist">
<li>
...
</li>
<li>
...
</li>
<li>
...
</li>
</ul>
</div>
</div>
</div>
If that bunch of li elements are bigger than the col-sm-8's width they will jump to the next line.
I want to add a horizontal scrollbar so all the li elements are in the same li only visible at col-sm-8's width with the possibility to scroll horizontally through them.
I tried setting a fixed height to the wrapper (so only one row can be seen) and adding overflow-y hidden and white-space nowrap but it's not working:
#playlist-wrapper{
height: 150px;
overflow-y: hidden;
overflow: auto;
Tried also with overflow-x: scroll;
white-space: nowrap;
}
Also tried:
#playlist-wrapper ul {
white-space: nowrap;
}
Rest of the css not affecting the overflow just to make it a horizontal list and some text/color properties.
ul#playlist {
list-style-type: none;
margin: 0;
padding: 0;
background-color: black;
}
ul#playlist li {
float: left;
margin-left: 10px;
margin-top: 20px;
}
ul#playlist li p {
text-align: center;
color: white;
font-weight: bold;
text-decoration: none;
}
With that css I am having a vertical scrollbar. Is it possible to have a horizontal scrollbar somehow?
Upvotes: 2
Views: 3585
Reputation: 764
I think that you need something like this
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
#playlist-wrapper ul li{
height: 50px;
overflow-y: hidden;
overflow: auto;
white-space: nowrap;
}
#playlist-wrapper{
height: 150px;
width:150px;
overflow-y: hidden;
overflow: auto;
white-space: nowrap;
}
</style>
</head>
<body>
<div class="row">
<div class="col-sm-2">
<div id="playlist-wrapper">
<ul id="playlist">
<li>Fabian Eduardo Sierra Pineda</li>
<li>Fabian Eduardo Sierra Pineda</li>
<li>Fabian Eduardo Sierra Pineda</li>
</ul>
</div>
</div>
</div>
</body>
</html>
Upvotes: 1