質問編集履歴
1
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -23,61 +23,4 @@
|
|
23
23
|
CD E
|
24
24
|
のように余白の32pxがない状態で並んでしまいます。
|
25
25
|
問題を起こしているのは下記のコードにもある
|
26
|
-
`nth-of-type(3n) {...}` の部分であることは明白なのですが、どのようにその問題を回避したら良いかわかりません。。
|
26
|
+
`nth-of-type(3n) {...}` の部分であることは明白なのですが、どのようにその問題を回避したら良いかわかりません。。
|
27
|
-
|
28
|
-
|
29
|
-
## ソースコード
|
30
|
-
|
31
|
-
```HTML
|
32
|
-
<div class="news-content-cards">
|
33
|
-
<% news.each do |article| %>
|
34
|
-
<%= link_to article.url(relative: true), class: "news-content-card news-content-#{cms_fragment_content(:category_en, article)} active" do %>
|
35
|
-
<% if cms_fragment_content(:hero_image, article).present? %>
|
36
|
-
<%= image_tag cms_fragment_content(:hero_image, article).first.variant(resize: '480x287').processed, class: "news-content-card-image", alt: "#{cms_fragment_content(:title, article)}>" %>
|
37
|
-
<% else %>
|
38
|
-
<%= image_tag "pages/cms/news/image.png", class: "news-content-card-image" %>
|
39
|
-
<% end %>
|
40
|
-
<div class="news-content-card-info">
|
41
|
-
<p class="news-date"><%= cms_fragment_content(:publish_date, article) %></p>
|
42
|
-
<h3 class="news-title"><%= cms_fragment_content(:title, article) %></h3>
|
43
|
-
<p class="news-category"><%= cms_fragment_content(:category_jp, article) %></p>
|
44
|
-
</div>
|
45
|
-
<% end %>
|
46
|
-
<% end %>
|
47
|
-
</div>
|
48
|
-
```
|
49
|
-
|
50
|
-
下記の3nの時にmargin-right:0 となっていることが原因で、optionタグを切り替えた時にもそれが残ってしまい、本来32px開けたい右側のマージンが残ってしまっている状況です。
|
51
|
-
|
52
|
-
```CSS
|
53
|
-
.news-content-cards .active:nth-of-type(3n) {
|
54
|
-
margin-right: 0;
|
55
|
-
|
56
|
-
@media screen and (max-width: 767px) {
|
57
|
-
margin: 0 0 32px;
|
58
|
-
}
|
59
|
-
|
60
|
-
@media screen and (max-width: 414px) {
|
61
|
-
margin: 0 auto 32px;
|
62
|
-
}
|
63
|
-
}
|
64
|
-
|
65
|
-
```
|
66
|
-
|
67
|
-
|
68
|
-
```javascript
|
69
|
-
$(function () {
|
70
|
-
$(".news-category-select-box").change(function () {
|
71
|
-
const $selectBoxValue = $(this).val();
|
72
|
-
$(".news-content-card").removeClass("active");
|
73
|
-
if ($selectBoxValue === "all") {
|
74
|
-
$(".news-content-card").addClass("active");
|
75
|
-
}
|
76
|
-
$(".news-content-" + $selectBoxValue).addClass("active");
|
77
|
-
})
|
78
|
-
});
|
79
|
-
```
|
80
|
-
|
81
|
-
いまはjQueryを使って実装していますが、いま開発しているプロダクトはVue.jsでもかけるようにになっているので、そちらの解決方法でも構いません。
|
82
|
-
|
83
|
-
よろしくお願いいたします!
|