0

I got code like this

.divA {
  background: red;
  width: 500px;
  display: flex;
  flex-direction: row;
  overflow-y: scroll;
}

.epi {
  width: 50%;
  background: blue;
}
<div class="divA">
  <div class="epi">
    <h1>dsds</h1>
    <p>sdsds</p>
    <img src="img/heart.png" alt="" />
  </div>
  <div class="epi">
    <h1>dsds</h1>
    <p>sdsds</p>
    <img src="img/heart.png" alt="" />
  </div>
  <div class="epi">
    <h1>dsds</h1>
    <p>sdsds</p>
    <img src="img/heart.png" alt="" />
  </div>
  <div class="epi">
    <h1>dsds</h1>
    <p>sdsds</p>
    <img src="img/heart.png" alt="" />
  </div>
</div>

I'm expecting this

enter image description here

But I'm getting this

enter image description here

I want item in .divA has the width of 50% of .divA

Pete
  • 54,116
  • 25
  • 104
  • 150
angry kiwi
  • 9,824
  • 23
  • 98
  • 151

1 Answers1

1

Edit: Since you don't want it to wrap, but scroll horizontally, you can put it as overflow-x: scroll;

.divA {
  background: red;
  width: 500px;
  display: flex;
  justify-content: flex-start;
  overflow-x: scroll;
  overflow-y: auto;
}

.epi {
  min-width: 50%;
  background: blue;
}
<div class="divA">
  <div class="epi">
    <h1>dsds</h1>
    <p>sdsds</p>
    <img src="img/heart.png" alt="" />
  </div>
  <div class="epi">
    <h1>dsds</h1>
    <p>sdsds</p>
    <img src="img/heart.png" alt="" />
  </div>
  <div class="epi">
    <h1>dsds</h1>
    <p>sdsds</p>
    <img src="img/heart.png" alt="" />
  </div>
  <div class="epi">
    <h1>dsds</h1>
    <p>sdsds</p>
    <img src="img/heart.png" alt="" />
  </div>
</div>
djolf
  • 1,094
  • 4
  • 18