I'm working on a very basic script in Ruby on Rails to display the records from a table, about CSS I'm using Flex but it is affecting the display (horizontally) of all items, this is the result:
The row in green is the header and the next one contains the data, the HTML code looks like this:
html, body{
margin: 0;
background-color: #3a3a3a;
}
body *{
color: white;
font-family: 'Segoe UI', Tahoma, Geneva, sans-serif;
display: flex;
justify-content: center;
flex-direction: row;
border-radius: 5px;
align-items: center;
}
div {
margin-left: 20px;
}
input {
color: black;
}
h1{
font-size: 2.5em;
}
.description{
background-color: rgba(9, 0, 0, 0.199);
padding: 2em;
font-size: 2em;
max-width: 600px;
}
.meta *{
display: flex;
background-color: yellow;
}
.links *{
margin-top: 10px;
color: white;
border-radius: 5px;
font-weight: bold;
background-color: rgb(31, 55, 133);
margin: 5px;
padding: 5px;
text-decoration: none;
}
#tabledata {
font-family: Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
#tabledata td, #tabledata th {
border: 1px solid #ddd;
padding: 8px;
}
#tabledata tr:nth-child(even){background-color: #f2f2f2;}
#tabledata tr:hover {background-color: #ddd;}
#tabledata th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #04AA6D;
color: white;
}
<p id="notice"><%= notice %></p>
<h1>Productlines</h1>
<table id="tabledata">
<thead>
<tr>
<th>Product Name</th>
<th>Available?</th>
<th colspan='3'>Options</th>
</tr>
</thead>
<tbody>
<% @productlines.each do |productline| %>
<tr>
<td><%=productline.name %></td>
<td><%=productline.isactive %></td>
<td class="links"><%= link_to 'Show', productline %></td>
<td class="links"><%= link_to 'Edit', edit_productline_path(productline) %></td>
<td class="links"><%= link_to 'Destroy', productline, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<span class="links"><%= link_to 'New Productline', new_productline_path %></span>
My question is: is there anyway to display the rows inside the table in vertical mode? Thanks a lot for your comments.
