How to create horizontal scroll using css flexbox?

flexbox horizontal scroll codepen
horizontal scroll css
horizontal scrolling div with arrows
flexbox vertical scroll
bootstrap horizontal scroll
css grid horizontal scroll
horizontal scrolling website tutorial
react-horizontal scroll

I would like to create a webpage with a section that scrolls horizontally using flexbox. However, the code results in each box being reduced in size to fit the screen, rather than overflowing and enabling for horizontal scrolling.

Code:

.main {
  flex-direction: row;
  -webkit-flex-direction: row;
  overflow: scroll;
  width: 100%;
  height: 100vh;
}

.portfolio_item {
  width: 50%;
}

.flex {
  display: flex !important;
  display: -webkit-flex !important;
}
<div class="main flex">
  <div class="portfolio_item willow">
    <a class="link" href="https://aubergewillowinn.com/">
      <div class="filter flex">
        <h3 class="portfolio_item-text">Willow Inn</h3>
      </div>
    </a>
  </div>
  <div class="portfolio_item bellevue">
    <a class="link" href="http://www.bellevuemtl.com/">
      <div class="filter flex">
        <h3 class="portfolio_item-text">Bellevue Condominiums</h3>
      </div>
    </a>
  </div>
  <div class="portfolio_item willow">
    <a class="link" href="https://aubergewillowinn.com/">
      <div class="filter flex">
        <h3 class="portfolio_item-text">Willow Inn</h3>
      </div>
    </a>
  </div>
  <div class="portfolio_item bellevue">
    <a class="link" href="http://www.bellevuemtl.com/">
      <div class="filter flex">
        <h3 class="portfolio_item-text">Bellevue Condominiums</h3>
      </div>
    </a>
  </div>
</div>

If you add a min-width of 50% (as well as the width of 50%) to your child portfolio items, your code works (with overflow and scrolling).

Hope this helps

.main {
  flex-direction: row;
  -webkit-flex-direction: row;
  overflow: scroll;
  width: 100%;
  height: 100vh;
}

.portfolio_item {  
  min-width: 50%;
  width:50%;
}

.flex {
  display: flex;
  display: -webkit-flex;
}
<div class="main flex">
  <div class="portfolio_item willow">
    <a class="link" href="https://aubergewillowinn.com/">
      <div class="filter flex">
        <h3 class="portfolio_item-text">Willow Inn</h3>
      </div>
    </a>
  </div>
  <div class="portfolio_item bellevue">
    <a class="link" href="http://www.bellevuemtl.com/">
      <div class="filter flex">
        <h3 class="portfolio_item-text">Bellevue Condominiums</h3>
      </div>
    </a>
  </div>
  <div class="portfolio_item willow">
    <a class="link" href="https://aubergewillowinn.com/">
      <div class="filter flex">
        <h3 class="portfolio_item-text">Willow Inn</h3>
      </div>
    </a>
  </div>
  <div class="portfolio_item bellevue">
    <a class="link" href="http://www.bellevuemtl.com/">
      <div class="filter flex">
        <h3 class="portfolio_item-text">Bellevue Condominiums</h3>
      </div>
    </a>
  </div>
</div>

How To Create Horizontal Scrolling Containers, Next step is to add styling so that the container scrolls horizontally. To do this I make the container display as flexbox. In addition, I am setting  Not sure if using flex is necessary, since flex is to help avoid the overflow situation amongst other things. Here is a very simple example without flexbox utilising the overflow-x: scroll; and white-space: nowrap; attributes. The first allows the div to be scrollable, and the second prevents white space from wrapping around to a new line


I'm not sure flexbox is actually the tool for this job. The premise behind flexbox is that your elements flex to fit inside the box. However, you specifically want them to overflow your box, not fill the available space in your box.

From css-tricks.com:

The main idea behind the flex layout is to give the container the ability to alter its items' width/height (and order) to best fill the available space [...] A flex container expands items to fill available free space, or shrinks them to prevent overflow.

It might make more sense to enable horizontal scrolling by using a layout based on inline-block and white-space: nowrap like this:

.main {
  overflow-x: auto;
  white-space: nowrap;
}

.portfolio_item {
  display: inline-block;
  margin: 0 30px;
}
<div class="main">
  <div class="portfolio_item willow">
    <a class="link" href="https://aubergewillowinn.com/">
      <div class="filter flex">
        <h3 class="portfolio_item-text">Willow Inn</h3>
      </div>
    </a>
  </div>
  <div class="portfolio_item bellevue">
    <a class="link" href="http://www.bellevuemtl.com/">
      <div class="filter flex">
        <h3 class="portfolio_item-text">Bellevue Condominiums</h3>
      </div>
    </a>
  </div>
  <div class="portfolio_item willow">
    <a class="link" href="https://aubergewillowinn.com/">
      <div class="filter flex">
        <h3 class="portfolio_item-text">Willow Inn</h3>
      </div>
    </a>
  </div>
  <div class="portfolio_item bellevue">
    <a class="link" href="http://www.bellevuemtl.com/">
      <div class="filter flex">
        <h3 class="portfolio_item-text">Bellevue Condominiums</h3>
      </div>
    </a>
  </div>
</div>

How to implement horizontal scrolling using Flexbox, Using the flex-wrap property to do most of the work we can achieve horizontal scrolling layout with flexbox, great for forms of navigation and easy to browse content. [1]: Make a flex container so all our items align as necessary [2]: bar in WebKit browsers */ .scroll { display: flex; /* [1] */ flex-wrap: nowrap;  Hiding the Scrollbar For UX reasons you may want to hide the scrollbar, and still have a scrollable section. There’s an easy way out — for webkit browsers at least.


Not sure if using flex is necessary, since flex is to help avoid the overflow situation amongst other things.

Here is a very simple example without flexbox utilising the overflow-x: scroll; and white-space: nowrap; attributes. The first allows the div to be scrollable, and the second prevents white space from wrapping around to a new line

.container {
	overflow-x: scroll;
	white-space: nowrap;
}

.box {
	display: inline-block;
	border: 1px solid black;
	margin: 5px;
	height: 200px;
	width: 200px;
}
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="test.css">
  <title></title>
</head>
<body>
	<div class="container">
		<div class="box"></div>
		<div class="box"></div>
		<div class="box"></div>
		<div class="box"></div>
		<div class="box"></div>
		<div class="box"></div>
		<div class="box"></div>
		<div class="box"></div>
		<div class="box"></div>
		<div class="box"></div>
	</div>
</body>
</html>

Using flexbox for horizontal scrolling navigation • iamsteve, Enabling horizontal scroll in flexbox · css flexbox. I am new to flexbox, and I am trying to make a horizontal scrolling website. The idea is to  If you create websites, chances are you have been asked to create a horizontal scrolling component. It is extremely easy to implement this using just a few lines of Flexbox. Let me show you how. Project Layout. We need to create a container that will contain all the images that we want to scroll. Here is the code:


Enabling horizontal scroll in flexbox, How do you create a section that scrolls horizontally — with great my free CSS Grid cheat sheet, and also get two quality interactive Flexbox  With these changes, here is what our final horizontal scroll area looks like. Conclusion It is very easy to create a horizontal scroll area using flexbox. Thanks for reading. Training Courses I create training courses on my website CodePrep. I have training courses on Vue, Webpack, Flexbox, functional programming and more. Check it out here.


How to create horizontally scrollable sections with Flexbox, Make a <div> , and make a bunch of child elements. In this example, our side-​scrolling container will be 300px wide, with 8 items of 100×100px  I was tasked to create a vertical list that transforms to horizontal scrolling when sized down to mobile. This was the outcome: The two main takeaways from this came from using CSS's media queries and flexbox. I had only done some real quick and dirty CSS styling in the past so this was my first exposure to both of these two tools.


Pure CSS Horizontal Scrolling, Format on Save. If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting. Using the flex-wrap property to do most of the work we can achieve horizontal scrolling layout with flexbox, great for forms of navigation and easy to browse content. This post is a follow up to a different method for horizontal scrolling navigation which used inline-block.