jeudi 23 mai 2019

how to display flex column with css when calling each method on the object

I am trying to display:flex columns on each item(product), but resulted in showcasing it in a vertical layout(codes as below), I was wondering how do i showcase it in displaying as flex and also when in an asymmetrical layout column(when looping through each object) as well. thank you!

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
  box-sizing: border-box;
}

/* Create three equal columns that floats next to each other */
.column {
  display: flex;
  margin:20px;
  float: left;
  width: 33.33%;
  padding: 10px;
  height: 300px; /* Should be removed. Only for demonstration */
}

/* Clear floats after the columns */
.row:after {
  content: "";
  display: table;
  clear: both;
}
</style>

</head>
<body>

<h2>All Products</h2>
<% @products.each do |product| %>



<div class="row">
  <div class="column" style="background-color:#aaa;">
    <%= product.product_name %>
    <%= product.description %>
  </div>


</div>
<% end %>
</body>
</html>

Aucun commentaire:

Enregistrer un commentaire