質問編集履歴
1
コード追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -1 +1,93 @@
|
|
1
1
|
railsで2カラムでアイテムを並べたいと考えています。どうやるのが一番シンプルにできそうでしょうか?
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
```
|
6
|
+
|
7
|
+
<div class="row">
|
8
|
+
|
9
|
+
<div class="col-xs-12">
|
10
|
+
|
11
|
+
<% @posts.each do |post|
|
12
|
+
|
13
|
+
@genders = { 1 => "男",2 => "女",3 => "その他" }
|
14
|
+
|
15
|
+
%>
|
16
|
+
|
17
|
+
<a href="/posts/<%= post.id %>">
|
18
|
+
|
19
|
+
<div class="card index_card">
|
20
|
+
|
21
|
+
<img class="card-img-top" src="/images/index_thum_01.png" alt="Card image cap">
|
22
|
+
|
23
|
+
<div class="card-body">
|
24
|
+
|
25
|
+
<div class="row">
|
26
|
+
|
27
|
+
<p class="font_02 col-md-12"><%= link_to(post.title,"/posts/#{post.id}") %></p>
|
28
|
+
|
29
|
+
<p class="font_03 col-md-12"><%= post.description %></p>
|
30
|
+
|
31
|
+
<div class="col-xs-12">
|
32
|
+
|
33
|
+
<% # tag
|
34
|
+
|
35
|
+
if TagMap.find_by(post_id: post.id)
|
36
|
+
|
37
|
+
@tag_map_id = TagMap.find_by(post_id: post.id)
|
38
|
+
|
39
|
+
@tag_list = Tag.find_by(id: @tag_map_id.tag_id).name
|
40
|
+
|
41
|
+
%>
|
42
|
+
|
43
|
+
<p>タグ:#<%= @tag_list %></p>
|
44
|
+
|
45
|
+
<% else %>
|
46
|
+
|
47
|
+
<% end %>
|
48
|
+
|
49
|
+
</div><!-- 12 -->
|
50
|
+
|
51
|
+
</div><!-- row -->
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
<div class="row">
|
56
|
+
|
57
|
+
<div class="col-md-7">
|
58
|
+
|
59
|
+
<%= post.line_id %>
|
60
|
+
|
61
|
+
</div><!-- 6 -->
|
62
|
+
|
63
|
+
<div class="col-md-3">
|
64
|
+
|
65
|
+
<%= post.location %>
|
66
|
+
|
67
|
+
</div><!-- 4 -->
|
68
|
+
|
69
|
+
<div class="col-md-2">
|
70
|
+
|
71
|
+
<%= @genders[post.gender] %>
|
72
|
+
|
73
|
+
</div><!-- 2 -->
|
74
|
+
|
75
|
+
</div><!--panel-footer-->
|
76
|
+
|
77
|
+
</div><!-- card-body -->
|
78
|
+
|
79
|
+
</div><!-- card -->
|
80
|
+
|
81
|
+
</a>
|
82
|
+
|
83
|
+
<% end %>
|
84
|
+
|
85
|
+
</div>
|
86
|
+
|
87
|
+
</div>
|
88
|
+
|
89
|
+
```
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
上記のコードで書いていてcardを2列で並べたいのですが2こずつ繰り返す方法がわからず困っています。1こずつ生成なので現在だと片方が高さが高いとずれてしまうため2個で1列になり高さがずれないようにしたいです。
|