質問編集履歴

4

コード変更

2022/03/06 06:06

投稿

deango
deango

スコア161

test CHANGED
File without changes
test CHANGED
@@ -28,126 +28,14 @@
28
28
 
29
29
  {% block contents %}
30
30
  <div class="container">
31
- <div class="row align-item-center mx-auto">
31
+ <div class="row">
32
32
  <div class="my-div-style">
33
33
  <div class="col-6">
34
- <div class="clearfix">
35
- <a class="btn btn-primary float-right mb-5" href="{% url 'diary:diary_create' %}">新規作成</a>
36
- </div>
37
- {% for diary in diary_list %}
38
- <div class="post-preview">
39
- <div href="{% url 'diary:diary_detail' diary.pk %}">
40
- <div class="text-center">
41
- <h2 class="post-title">
42
- {{ diary.title }}
43
- </h2>
44
- {% if diary.photo1 %}
45
- <img src="{{ diary.photo1.url }}" width="400px" height=auto />
46
- {% endif %}
47
- <h3 class="post-subtitle">
48
- {{ diary.content|truncatechars:20 }}
49
- </h3>
50
- </div>
51
- </div>
52
- <p class="post-meta">{{ diary.created_at }}</p>
53
- </div>
54
- <hr>
55
- {% empty %}
56
- <p>日記がありません。</p>
57
- {% endfor %}
58
-
59
- <!-- ページネーション処理 -->
60
- {% if is_paginated %}
61
- <ul class="pagination">
62
- <!-- 前ページへのリンク -->
63
- {% if page_obj.has_previous %}
64
- <li class="page-item">
65
- <a class="page-link" href="?page={{ page_obj.previous_page_number }}">
66
- <span aria-hidden="true">&laquo;</span>
67
- </a>
34
+ <--!日記-->
68
- </li>
69
- {% endif %}
70
-
71
- <!-- ページ数表示 -->
72
- {% for page_num in page_obj.paginator.page_range %}
73
-
74
- {% if page_obj.number == page_num %}
75
- <li class="page-item active"><a class="page-link" href="#">{{ page_num }}</a></li>
76
- {% else %}
77
- <li class="page-item"><a class="page-link" href="?page={{ page_num }}">{{ page_num }}</a></li>
78
- {% endif %}
79
- {% endfor %}
80
-
81
- <!-- 次ページへのリンク -->
82
- {% if page_obj.has_next %}
83
- <li class="page-item">
84
- <a class="page-link" href="?page={{ page_obj.next_page_number }}">
85
- <span aria-hidden="true">&raquo;</span>
86
- </a>
87
- </li>
88
- {% endif %}
89
- </ul>
90
- {% endif %}
91
35
  </div>
92
36
  <div class="col-6">
93
- <div class="clearfix">
37
+      <--!日記-->
94
- <a class="btn btn-primary float-right mb-5" href="{% url 'diary:diary_create' %}">新規作成</a>
95
- </div>
38
+ </div>
96
- {% for diary in diary_list %}
97
- <div class="post-preview">
98
- <div href="{% url 'diary:diary_detail' diary.pk %}">
99
- <div class="text-center">
100
- <h2 class="post-title">
101
- {{ diary.title }}
102
- </h2>
103
- {% if diary.photo1 %}
104
- <img src="{{ diary.photo1.url }}" width="400px" height=auto />
105
- {% endif %}
106
- <h3 class="post-subtitle">
107
- {{ diary.content|truncatechars:20 }}
108
- </h3>
109
- </div>
110
- </div>
111
- <p class="post-meta">{{ diary.created_at }}</p>
112
- </div>
113
- <hr>
114
- {% empty %}
115
- <p>日記がありません。</p>
116
- {% endfor %}
117
-
118
- <!-- ページネーション処理 -->
119
- {% if is_paginated %}
120
- <ul class="pagination">
121
- <!-- 前ページへのリンク -->
122
- {% if page_obj.has_previous %}
123
- <li class="page-item">
124
- <a class="page-link" href="?page={{ page_obj.previous_page_number }}">
125
- <span aria-hidden="true">&laquo;</span>
126
- </a>
127
- </li>
128
- {% endif %}
129
-
130
- <!-- ページ数表示 -->
131
- {% for page_num in page_obj.paginator.page_range %}
132
-
133
- {% if page_obj.number == page_num %}
134
- <li class="page-item active"><a class="page-link" href="#">{{ page_num }}</a></li>
135
- {% else %}
136
- <li class="page-item"><a class="page-link" href="?page={{ page_num }}">{{ page_num }}</a></li>
137
- {% endif %}
138
- {% endfor %}
139
-
140
- <!-- 次ページへのリンク -->
141
- {% if page_obj.has_next %}
142
- <li class="page-item">
143
- <a class="page-link" href="?page={{ page_obj.next_page_number }}">
144
- <span aria-hidden="true">&raquo;</span>
145
- </a>
146
- </li>
147
- {% endif %}
148
- </ul>
149
- {% endif %}
150
- </div>
151
39
  </div>
152
40
  </div>
153
41
  </div>

3

本文修正

2022/03/05 13:14

投稿

deango
deango

スコア161

test CHANGED
File without changes
test CHANGED
@@ -1,8 +1,8 @@
1
1
  djangoでWEBアプリを作成しており、bootstrapを使用したHTML5のレイアウトについて質問です。
2
2
  ブロックを横並びに配置したいのですが、下に配置されてしまいます。
3
3
  col-6でrow(width 100%)の中の半分を指定しています。
4
- グリッドについては学習して、cssのcontainerかrowの設定がおかしそうなので、
4
+
5
- cssコード確認いただきたいです。
5
+ html記述に問題ありそうです。
6
6
 
7
7
  他のページもあるので、このbootstrapで統一して作成したいと思っています。
8
8
 
@@ -153,68 +153,4 @@
153
153
  </div>
154
154
  {% endblock %}
155
155
  ```
156
- ```css(関係ありそうな分のみ)
157
- .container,
158
- .container-fluid,
159
- .container-xxl,
160
- .container-xl,
161
- .container-lg,
162
- .container-md,
163
- .container-sm {
164
- width: 100%;
165
- padding-right: var(--bs-gutter-x, 0.75rem);
166
- padding-left: var(--bs-gutter-x, 0.75rem);
167
- margin-right: auto;
168
- margin-left: auto;
169
- }
170
156
 
171
- @media (min-width: 576px) {
172
- .container-sm, .container {
173
- max-width: 540px;
174
- }
175
- }
176
- @media (min-width: 768px) {
177
- .container-md, .container-sm, .container {
178
- max-width: 720px;
179
- }
180
- }
181
- @media (min-width: 992px) {
182
- .container-lg, .container-md, .container-sm, .container {
183
- max-width: 960px;
184
- }
185
- }
186
- @media (min-width: 1200px) {
187
- .container-xl, .container-lg, .container-md, .container-sm, .container {
188
- max-width: 1140px;
189
- }
190
- }
191
- @media (min-width: 1400px) {
192
- .container-xxl, .container-xl, .container-lg, .container-md, .container-sm, .container {
193
- max-width: 1320px;
194
- }
195
- }
196
-
197
- .row {
198
- --bs-gutter-x: 1.5rem;
199
- --bs-gutter-y: 0;
200
- display: flex;
201
- flex-wrap: wrap;
202
- margin-top: calc(-1 * var(--bs-gutter-y));
203
- margin-right: calc(-0.5 * var(--bs-gutter-x));
204
- margin-left: calc(-0.5 * var(--bs-gutter-x));
205
- }
206
- .row > * {
207
- flex-shrink: 0;
208
- width: 100%;
209
- max-width: 100%;
210
- padding-right: calc(var(--bs-gutter-x) * 0.5);
211
- padding-left: calc(var(--bs-gutter-x) * 0.5);
212
- margin-top: var(--bs-gutter-y);
213
- }
214
-
215
- .col-6 {
216
- flex: 0 0 auto;
217
- width: 50%;
218
- }
219
- ```
220
-

2

本文追記しました。

2022/03/05 12:42

投稿

deango
deango

スコア161

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,10 @@
1
1
  djangoでWEBアプリを作成しており、bootstrapを使用したHTML5のレイアウトについて質問です。
2
- ブロックを横並びに配置したいのですが、large画面で見ても下に配置されてしまいます。
2
+ ブロックを横並びに配置したいのですが、下に配置されてしまいます。
3
- col-lg-6でrow(width 100%)の中の半分を指定しています。
3
+ col-6でrow(width 100%)の中の半分を指定しています。
4
+ グリッドについては学習して、cssのcontainerかrowの設定がおかしそうなので、
5
+ cssのコード確認いただきたいです。
6
+
7
+ 他のページもあるので、このbootstrapで統一して作成したいと思っています。
4
8
 
5
9
  使用しているフレームワーク等は以下です。
6
10
  ・django 4.0.2
@@ -26,7 +30,7 @@
26
30
  <div class="container">
27
31
  <div class="row align-item-center mx-auto">
28
32
  <div class="my-div-style">
29
- <div class="col-lg-6">
33
+ <div class="col-6">
30
34
  <div class="clearfix">
31
35
  <a class="btn btn-primary float-right mb-5" href="{% url 'diary:diary_create' %}">新規作成</a>
32
36
  </div>
@@ -85,7 +89,7 @@
85
89
  </ul>
86
90
  {% endif %}
87
91
  </div>
88
- <div class="col-lg-6">
92
+ <div class="col-6">
89
93
  <div class="clearfix">
90
94
  <a class="btn btn-primary float-right mb-5" href="{% url 'diary:diary_create' %}">新規作成</a>
91
95
  </div>
@@ -207,9 +211,10 @@
207
211
  padding-left: calc(var(--bs-gutter-x) * 0.5);
208
212
  margin-top: var(--bs-gutter-y);
209
213
  }
214
+
210
- .col-lg-6 {
215
+ .col-6 {
211
- flex: 0 0 auto;
216
+ flex: 0 0 auto;
212
- width: 50%;
217
+ width: 50%;
213
- }
218
+ }
214
219
  ```
215
220
 

1

コードが一部崩れていたので修正しました

2022/03/05 09:29

投稿

deango
deango

スコア161

test CHANGED
File without changes
test CHANGED
@@ -85,7 +85,7 @@
85
85
  </ul>
86
86
  {% endif %}
87
87
  </div>
88
- <div class="col-lg-6">
88
+ <div class="col-lg-6">
89
89
  <div class="clearfix">
90
90
  <a class="btn btn-primary float-right mb-5" href="{% url 'diary:diary_create' %}">新規作成</a>
91
91
  </div>