Please tell me how to post it side by side on the index page.

Asked 1 years ago, Updated 1 years ago, 82 views

Thank you for your help.I'm a beginner at rails.I'm creating a recipe app with rails4.

I would like to list the contents stored in the model side by side on the index page.
How should I arrange it?

Currently, I only understand .each loop, and they are lined up vertically.

<Current code: index.html.erb>

<%@recipes.each do |recipe|%>
        <%=link_to recipe do%>
          <%=image_tag recipe.image.url(:thumb)%>
        <%end%>
        <h2><%=link_to recipe.title, recipe%>/2>

Enter a description of the image here

Thank you for your cooperation.

ruby-on-rails html css

2022-09-30 21:29

2 Answers

I think there are many ways, but I will post a sample using flexbox.

https://codepen.io/itmammoth/pen/mpewWa

Please edit erb to output html like this.
Search flexbox for more information such as margins and alignment.


2022-09-30 21:29

The H tag has a headline, so I don't think it's appropriate to use it for elements that you want to line up horizontally like the layout you want.
"Would it be possible to set up a table and output ""image column"" and ""cooking name column"" in order?"


2022-09-30 21:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.