質問するログイン新規登録

質問編集履歴

3

本文訂正

2021/09/13 00:09

投稿

art35
art35

スコア13

title CHANGED
File without changes
body CHANGED
@@ -1,6 +1,6 @@
1
1
  Djangoのフロントエンドを作成しています。
2
2
  フレームワークはBootstrapを使っていますが、Floating labelsのExmpleを使ったところ、
3
- usernameとPasswordのラベルが画面中央ではなく、画面左上側に寄っています。
3
+ usernameとPasswordのinputタグの部分が画面中央ではなく、画面左上側に寄っています。
4
4
  中央表示したく、調べてみたもののどれもうまくいきませんでした。
5
5
  対応策がわかる方がお見えでしたらご教授ください。
6
6
  よろしくお願いいたします。

2

問題点の写真添付

2021/09/13 00:09

投稿

art35
art35

スコア13

title CHANGED
File without changes
body CHANGED
@@ -101,4 +101,6 @@
101
101
 
102
102
  </body>
103
103
  </html>
104
- ```
104
+ ```
105
+
106
+ ![イメージ説明](c3ecffefa17870c1f810c44c1a544298.png)

1

コードの追加

2021/09/13 00:04

投稿

art35
art35

スコア13

title CHANGED
File without changes
body CHANGED
@@ -29,4 +29,76 @@
29
29
  </body>
30
30
 
31
31
  {% endblock content %}
32
+ ```
33
+
34
+ 修正1
35
+ ```html
36
+ {% extends 'base.html' %}
37
+
38
+ {% block content %}
39
+
40
+ {% block customcss %}
41
+ <link href="{% static 'style_log.css' %}" rel="stylesheet">
42
+ {% endblock customcss %}
43
+
44
+ <body class="text-center">
45
+ {{ context }}
46
+ <form method="POST">{% csrf_token %}<form>
47
+ <h1 class="h3 mb-3 fw-normal">Please login</h1>
48
+ <div class="form-floating" style="width:30%">
49
+ <input type="text" class="form-control" id="floatingInput" placeholder="Username" name='username'>
50
+ <label for="floatingInput">username</label>
51
+ </div>
52
+ <div class="form-floating" style="width:30%">
53
+ <input type="password" class="form-control" id="floatingPassword" placeholder="Password" name='password'>
54
+ <label for="floatingPassword">Password</label>
55
+ </div>
56
+ <button class="btn btn-lg btn-success" type="submit" style="width:30%">login</button>
57
+ <p class="mt-5 mb-3 text-muted">&copy; 2017-2021</p>
58
+ </form>
59
+ </body>
60
+
61
+ {% endblock content %}
62
+ ```
63
+
64
+ ```css
65
+ style_log.css
66
+
67
+ .form-floating > .form-control:focus ~ label, .form-floating > .form-control:not(:placeholder-shown) ~ label, .form-floating > .form-select ~ label {
68
+ width: 118%;
69
+ text-align: center;
70
+ }
71
+ コード
72
+ ```
73
+
74
+ ```html
75
+ base.html
76
+
77
+ <!doctype html>
78
+ <html lang="en">
79
+ <head>
80
+ <!-- Required meta tags -->
81
+ <meta charset="utf-8">
82
+ <meta name="viewport" content="width=device-width, initial-scale=1">
83
+
84
+ <!-- Bootstrap CSS -->
85
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
86
+
87
+ {% block customcss %}
88
+
89
+ {% endblock customcss %}
90
+
91
+ <title>base.html</title>
92
+ </head>
93
+
94
+ <body>
95
+
96
+ {% block header %}
97
+ {% endblock header %}
98
+
99
+ {% block content %}
100
+ {% endblock content %}
101
+
102
+ </body>
103
+ </html>
32
104
  ```