简体   繁体   English

部分未正确堆叠 CSS

[英]Sections not stacking properly CSS

I want each section to stack side by side in rows of 2, the sections may keep growing whenever a new user is added so there may be well over 8 in the case of it not fitting on screen I need it to change into rows of 4 or 3. Im running into an issue where I can't even get the first 3 to fit properly on screen.我希望每个部分以 2 行并排堆叠,每当添加新用户时,这些部分可能会不断增长,因此如果它不适合屏幕,则可能超过 8 个我需要将其更改为 4 行或 3. 我遇到了一个问题,我什至无法让前 3 个正确显示在屏幕上。 I want a row of 2 and then one on the bottom but it just makes rows of 1 and I have to scroll to see the bottom 2..我想要一排 2,然后在底部有一个,但它只是排 1,我必须滚动才能看到底部 2..

HTML Code: HTML 代码:

<main class="room-main">
    <section id="room-name-wrapper">
        <p>Room Name: <span id="room-name"></span></p>
    </section>

    <section id="video-streams">
        <div class="video-container" id="user-container-1">
            <div class="username-wrapper" ><span class="user-name" > My Name </span></div>
            <div class="video-player" id="user-1"></div>
        </div>

    </section>

    <section id="video-streams">
        <div class="video-container" id="user-container-2">
            <div class="username-wrapper" ><span class="user-name" > My Name </span></div>
            <div class="video-player" id="user-2"></div>
        </div>

    </section>

    <section id="video-streams">
        <div class="video-container" id="user-container-3">
            <div class="username-wrapper" ><span class="user-name" > My Name </span></div>
            <div class="video-player" id="user-3"></div>
        </div>

    </section>
</main>

CSS Code: CSS 代码:

#video-streams{
    color: #FEA832;
    background-color: #FEA832;
    display: flex;
    flex-wrap: wrap;
    height: 85vh;
    width: 75%;
    margin: 0 auto;
}

.video-container{
    color: #FEA832;
    flex-basis: 500px;
    flex-grow: 1;
    max-height: 100%;
    min-height: 350px;
    border: 1px solid;
    border-radius: 5px;
    margin: 2px;
    background-color: #212121;
}

You can wrap the video-container in a big container like this:您可以像这样将video-container包装在一个大容器中:

<div class="container">
  <section id="video-streams">
      <div class="video-container" id="user-container-1">
          <div class="username-wrapper" ><span class="user-name" > My Name </span></div>
          <div class="video-player" id="user-1"></div>
      </div>

  </section>

  <section id="video-streams">
      <div class="video-container" id="user-container-2">
          <div class="username-wrapper" ><span class="user-name" > My Name </span></div>
          <div class="video-player" id="user-2"></div>
      </div>

  </section>

  <section id="video-streams">
      <div class="video-container" id="user-container-3">
          <div class="username-wrapper" ><span class="user-name" > My Name </span></div>
          <div class="video-player" id="user-3"></div>
      </div>

  </section>
</div>

Then you can start styling from there然后你可以从那里开始造型

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM