visit
.cat-container {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
padding-bottom: 45px;
}
.text-box {
display: flex;
padding-left: 15px;
padding-right: 15px;
padding-bottom: 0;
flex-direction: column;
justify-content: space-around;
}
def show
@articles = Category
.find(params[:id])
.articles
.order('created_at desc')
end
<div class="cat-container">
<% @articles.each do |article| %>
<div class="image-box" style="background-image: url(<%= image_path "#{article.image}"%>);background-position: center; background-size:
cover; background-repeat: no-repeat;">
</div>
<div class="text-box">
<h2 class="art-author"><span><%=article.author.name%></span></h2>
<h2 class="art-title"><%= article.title %></h2>
<p class="art-text"><%= article.text.truncate(100) %></p>
<%= vote_or_unvote_btn(article)%>
</div>
<% end %>
</div>
<div class="cat-container">
<% x = 0 %>
<% @articles.each do |article| %>
<% if x == 4 %>
<% x = 0 %>
<%end%>
<% if x < 2 %>
<% x += 1%>
<div class="image-box" style="background-image: url(<%= image_path "#{article.image}"%>);background-position: center; background-size:
cover; background-repeat: no-repeat;">
</div>
<div class="text-box">
<h2 class="art-author"><span><%=article.author.name%></span></h2>
<h2 class="art-title"><%= article.title %></h2>
<p class="art-text"><%= article.text.truncate(100) %></p>
<%= vote_or_unvote_btn(article)%>
</div>
<% else %>
<% x += 1%>
<div class="text-box">
<h2 class="art-author"><span><%=article.author.name%></span></h2>
<h2 class="art-title"><%= article.title %></h2>
<p class="art-text"><%= article.text.truncate(100) %></p>
<p class="vote"><%= link_to('VOTE', article_votes_path(article_id: article.id), method: :post) %></p>
</div>
<div class="image-box" style="background-image: url(<%= image_path "#{article.image}"%>);background-position: center; background-size:
cover; background-repeat: no-repeat;">
</div>
<% end %>
<% end %>
</div>