Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I Am New To Coding CSS/HTML And My Cards Will Not Line Up Into A Row

Im new to HTML and im trying to make a row of cards but the cards are staying in a column and not going into a row like my flex-direction should tell them to go.Thanks for the help everybody! I hope i can finish this project 🙂

I want it to look like this

https://css-tricks.com/snippets/css/a-guide-to-flexbox/

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

but it looks like this

image.png

body {
  font-family: 'Open Sans', sans-serif;
}

.shell {
  flex-direction: row;
  border: 1px solid #EF9A9A;
  flex-basis: auto;
  margin: 5px;
}

.card {
  width: 150px;
  display: flex;
  flex-direction: column;
  border: 1px solid #EF9A9A;
  border-radius: 4px;
  overflow: hidden;
  margin: 0px;
}

.card-header {
  color: #D32F2F;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid #EF9A9A;
  background-color: #FFEBEE;
  padding: 5px 10px;
}

.card-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 15px 0;
}

.material-icons {
  font-size: 36px;
  color: #D32F2F;
  margin-bottom: 5px;
}

.main-description {
  color: #D32F2F;
  font-size: 12px;
  text-align: center;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
}

.header {
  overflow: hidden;
  background-color: #FFEBEE;
  padding: 20px 10px;
  border-bottom: 1px solid #EF9A9A;
  border-radius: 4px;
}

.header a {
  float: left;
  color: #D32F2F;
  text-align: center;
  padding: 12px;
  text-decoration: none;
  font-size: 18px;
  line-height: 25px;
  border-radius: 4px;
}

.header a.logo {
  font-size: 25px;
  font-weight: bold;
}

.header a:hover {
  background-color: #dfd5d7;
  color: #942626;
}

.header a.active {
  background-color: #D32F2F;
  color: #FFEBEE;
}

.header-right {
  float: right;
}

@media screen and (max-width: 500px) {
  .header a {
    float: none;
    display: block;
    text-align: left;
  }
  .header-right {
    float: none;
  }
}
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600" rel="stylesheet">

<div class="header">
  <a href="#home" class="logo">Project-LuLo</a>
  <div class="header-right">
    <a class="active" href="#home">Home</a>
    <a href="#games">Games</a>
    <a href="#contact">Contact</a>
  </div>
</div>

<div class="shell">
  <div class="card">
    <div class="card-header">Games</div>
    <div class="card-main">
      <i class="material-icons">videogame_asset</i>
      <div class="main-description">Web Based Games</div>
    </div>
  </div>

  <div class="card">
    <div class="card-header">Games</div>
    <div class="card-main">
      <i class="material-icons">videogame_asset</i>
      <div class="main-description">Web Based Games</div>
    </div>
  </div>
</div>

>Solution :

On your class .shell you had styles to dictate what to do with display: flex; but the shell class itself also needed to have display flex on it.

body {
  font-family: 'Open Sans', sans-serif;
}

.shell{
display: flex;
flex-direction:row;
border: 1px solid #EF9A9A;  
flex-basis: auto;
margin:5px;
}

.card {
  width: 150px;                
  display: flex;              
  flex-direction: column;       
  border: 1px solid #EF9A9A;    
  border-radius: 4px;
  overflow: hidden;
  margin: 0px;              
}


.card-header {
  color: #D32F2F;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid #EF9A9A;
  background-color: #FFEBEE;
  padding: 5px 10px;
}

.card-main {
  display: flex;              
  flex-direction: column;     
  justify-content: center;    
  align-items: center;        
  padding: 15px 0;            
}

.material-icons {
  font-size: 36px;
  color: #D32F2F;
  margin-bottom: 5px;
}

.main-description {
  color: #D32F2F;
  font-size: 12px;
  text-align: center;
}

* {box-sizing: border-box;}

body { 
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
}

.header {
  overflow: hidden;
  background-color: #FFEBEE;
  padding: 20px 10px;
  border-bottom: 1px solid #EF9A9A;
   border-radius: 4px;
}

.header a {
  float: left;
  color: #D32F2F;
  text-align: center;
  padding: 12px;
  text-decoration: none;
  font-size: 18px; 
  line-height: 25px;
  border-radius: 4px;
}

.header a.logo {
  font-size: 25px;
  font-weight: bold;
}

.header a:hover {
  background-color: #dfd5d7;
  color: #942626;
}

.header a.active {
  background-color: #D32F2F;
  color: #FFEBEE;
}

.header-right {
  float: right;
}

@media screen and (max-width: 500px) {
  .header a {
    float: none;
    display: block;
    text-align: left;
  }
  
  .header-right {
    float: none;
  }
}
<!DOCTYPE html>
   <head>
      <meta charset="utf-8"/>
     <title>Project-LuLo</title>
     <meta content="width=device-width, initial-scale=1" name="viewport"/>
      
   </head>
    <body>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600" rel="stylesheet">

<div class="header">
  <a href="#home" class="logo">Project-LuLo</a>
  <div class="header-right">
    <a class="active" href="#home">Home</a>
    <a href="#games">Games</a>
    <a href="#contact">Contact</a>
  </div>
</div>

<div class="shell"> 
<div class="card">
  <div class="card-header">Games</div>
  <div class="card-main">
    <i class="material-icons">videogame_asset</i>
    <div class="main-description">Web Based Games</div>
  </div>
</div>

<div class="card">
  <div class="card-header">Games</div>
  <div class="card-main">
    <i class="material-icons">videogame_asset</i>
    <div class="main-description">Web Based Games</div>
  </div>
</div>
</div>

    </body>
</html>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading