Skip to content Skip to sidebar Skip to footer

How To Make Horizontal Scroll On Page

I have div in which placed inner divs i need to make all inner divs in line and horizontal scrollbar should be displayed (i know it sounds crazy, but i need that). I tried containe

Solution 1:

Use white-space: nowrap; on #items

#items{
    overflow-x: scroll;
    width: auto;
    white-space: nowrap;
}

DEMO

Solution 2:

simply give #items to height and overflow-x:auto.

#items{
      overflow-x: auto;
      width: auto;
       height: 200px;
      }

Solution 3:

<divstyle="overflow-x:scroll;"><divstyle="width:1600px;"><divstyle="width:1500px;"><table><tr><td>  Your Value  </td></tr></table></div></div></div>

Solution 4:

I think you want something like this...

:root {
  --gutter: 20px;
}

.app {
  padding: var(--gutter) 0;
  display: grid;
  grid-gap: var(--gutter) 0;
  grid-template-columns: var(--gutter) 1fr var(--gutter);
  align-content: start;
}

.app > * {
  grid-column: 2 / -2;
}

.app > .full {
  grid-column: 1 / -1;
}

.hs {
  display: grid;
  grid-gap: calc(var(--gutter) / 2);
  grid-template-columns: repeat(6, calc(50% - var(--gutter) * 2));
  grid-template-rows: minmax(150px, 1fr);
  
  overflow-x: scroll;
  scroll-snap-type: x proximity;
  padding-bottom: calc(.75 * var(--gutter));
  margin-bottom: calc(-.25 * var(--gutter));
}


/* Demo styles */html,
body {
  height: 100%;
}

body {
  display: grid;
  place-items: center;
  background: #456173;
}

ul {
  list-style: none;
  padding: 0;
}

h1,
h2,
h3 {
  margin: 0;
}

.app {
  width: 375px;
  height: 667px;
  background: #DBD0BC;
  overflow-y: scroll;
}

.hs > li,
.item {
  scroll-snap-align: center;
  padding: calc(var(--gutter) / 2 * 1.5);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: #fff;
  border-radius: 8px;
}
<divclass="app"><h1>Some headline</h1><ulclass="hs"><liclass="item">test</li><liclass="item">test</li><liclass="item">test</li><liclass="item">test</li><liclass="item">test</li><liclass="item">test</li></ul><divclass="container"><divclass="item"><h3>Block for context</h3></div></div></div>

Post a Comment for "How To Make Horizontal Scroll On Page"