How do I fill up the page grid and lay out the content widths in a single column?

后端 未结 1 719
醉话见心
醉话见心 2021-01-26 18:16

I\'m trying to create flex box columns for web development. However, all I managed to do is produce one column of flex boxes.

What are some basic CSS codes that would ve

相关标签:
1条回答
  • 2021-01-26 18:41

    On your section CSS, change flexbox to flex and it shall work.

    @charset "utf-8";
    
    /*
          CSS Code
        */
    
    section {
      display: flex; /* Change from flexbox to flex */
      flex-direction: row;
      flex-wrap: wrap-reverse;
    }
    
    div.card {
      display: flex;
      flex-basis: 200px;
      flex-grow: 1;
      flex-shrink: 1;
      flex-direction: column;
      flex-wrap: nowrap;
      justify-content: space-between;
      align-items: center;
    }
    <!doctype html>
    <html lang="en">
    
    <head>
      <!--
          HTML Code  
           -->
      <meta charset="utf-8">
      <title>Coding Challenge 5-2</title>
      <link href="code5-2_layout.css" rel="stylesheet" />
      <link href="code5-2_flex.css" rel="stylesheet" />
    </head>
    
    <body>
    
      <h1>Social Media Sites</h1>
    
      <section>
        <div class="card">
          <header>
            <h1>Facebook</h1>
          </header>
          <img src="facebook.png" alt="Facebook" class="icon" />
          <footer>238,150 followers</footer>
        </div>
        <div class="card">
          <header>
            <h1>Twitter</h1>
          </header>
          <img src="twitter.png" alt="Twitter" class="icon" />
          <footer>48,871 followers</footer>
        </div>
        <div class="card">
          <header>
            <h1>Instagram</h1>
          </header>
          <img src="instagram.png" alt="Instagram" class="icon" />
          <footer>171,244 followers</footer>
        </div>
        <div class="card">
          <header>
            <h1>GooglePlus</h1>
          </header>
          <img src="google-plus.png" alt="GooglePlus" class="icon" />
          <footer>64,288 followers</footer>
        </div>
        <div class="card">
          <header>
            <h1>YouTube</h1>
          </header>
          <img src="youtube.png" alt="YouTube" class="icon" />
          <footer>Subscribe to our Channel</footer>
        </div>
        <div class="card">
          <header>
            <h1>Vimeo</h1>
          </header>
          <img src="vimeo.png" alt="Vimeo" class="icon" />
          <footer>Get the Vimeo Feed</footer>
        </div>
        <div class="card">
          <header>
            <h1>Skype</h1>
          </header>
          <img src="share.png" alt="Skype" class="icon" />
          <footer>Join a Skype Chat</footer>
        </div>
        <div class="card">
          <header>
            <h1>Pinterest</h1>
          </header>
          <img src="pinterest.png" alt="Pinterest" class="icon" />
          <footer>Create your Page</footer>
        </div>
        <div class="card">
          <header>
            <h1>Bloggr</h1>
          </header>
          <img src="bloggr.png" alt="Bloggr" class="icon" />
          <footer>Subscribe to our Feed</footer>
        </div>
        <div class="card">
          <header>
            <h1>Tumblr</h1>
          </header>
          <img src="tumblr.png" alt="Tumblr" class="icon" />
          <footer>Get Daily Updates</footer>
        </div>
        <div class="card">
          <header>
            <h1>Share</h1>
          </header>
          <img src="share.png" alt="Share" class="icon" />
          <footer>Share our Content</footer>
        </div>
        <div class="card">
          <header>
            <h1>E-mail</h1>
          </header>
          <img src="email.png" alt="email" class="icon" />
          <footer>E-mail Us!</footer>
        </div>
      </section>
    </body>
    
    </html>

    0 讨论(0)
提交回复
热议问题