How to add a horizontal scroll in CSS?

1

Like, for example, the Netflix website when movies are rolling horizontally.

    
asked by anonymous 16.02.2015 / 22:20

2 answers

2

You can use display:inline-block with white-space:nowrap and overflow-x: scroll e      overflow-y: hidden More or less like this:

.scroll { 
    overflow-x: scroll;
    overflow-y: hidden;
    height: 200px;
    white-space:nowrap;
} 

img { 
    box-shadow: 1px 1px 10px #999; 
    margin: 2px;
    max-height: 150px;
    cursor: pointer;
    display:inline-block;
    *display:inline;
    *zoom:1;
    vertical-align:top;
}

See: link

    
16.02.2015 / 22:24
2

It depends on what you want to do. Essentially this is it:

body { //aqui pode ser outro elemento específico que quiser
    overflow-x: hidden; //se realmente quer impedir que tenha uma barra vertical.
    overflow-y: scroll; //pode-se usar auto para deixar o browser decidir quando usar.
    white-space: nowrap; //n]ao deixa quebrar a linha
}

The ideal is to apply the right techniques in specific situations. It would be easier to provide relevant responses if you had posted as you are using.

body { 
    overflow-x: scroll;
    overflow-y: hidden;
    white-space: nowrap;
} 
  <img src="http://lorempixel.com/150/150/people/0/a/"><imgsrc="http://lorempixel.com/150/150/people/0/b/">
  <img src="http://lorempixel.com/150/150/people/0/c/"><imgsrc="http://lorempixel.com/150/150/people/0/d/">
  <img src="http://lorempixel.com/150/150/people/0/e/"><imgsrc="http://lorempixel.com/150/150/people/0/f/">
    
16.02.2015 / 22:25