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
  • 57,112
  • 28
  • 117
  • 166
angry kiwi
  • 10,730
  • 26
  • 115
  • 161

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,196
  • 6
  • 18