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

質問編集履歴

2

投稿ページのheadにもjavascript読み込みのコードを記載しました。

2019/03/12 07:42

投稿

k.chisato
k.chisato

スコア18

title CHANGED
File without changes
body CHANGED
@@ -79,6 +79,7 @@
79
79
  <html>
80
80
  <head>
81
81
  <script src="new.js"></script>
82
+   <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
82
83
  </head>
83
84
  <body>
84
85
  <!--カード-->

1

コードを切り取って記載していたので、フルで記載し直しました。(まだ汚くて恥ずかしいですが・・・)

2019/03/12 07:42

投稿

k.chisato
k.chisato

スコア18

title CHANGED
File without changes
body CHANGED
@@ -25,28 +25,169 @@
25
25
  ### 該当のソースコード
26
26
 
27
27
  ```html
28
+ <!-- ここでmaterializeを読み込んでいます! -->
29
+ <!DOCTYPE html>
30
+ <html>
28
- <head>
31
+ <head>
29
- <script src="new.js"></script>
32
+ <meta charset="UTF-8" />
33
+ <title>LifeStampRally</title>
34
+ <style type="text/css" href="./style.css">
30
- </head>
35
+ </style>
36
+ <!-- Compiled and minified CSS -->
37
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
31
38
 
32
- <body>
33
- <div class="input-field col s12 country-select">
39
+ <!-- Compiled and minified JavaScript -->
40
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
41
+
34
- <select>
42
+ <!--CSS-->
35
- <optgroup label="team 1">
36
- <option value="1">Option 1</option>
43
+ <link rel="stylesheet" href="index.css">
37
- <option value="2">Option 2</option>
44
+
38
- </optgroup>
39
- <optgroup label="team 2">
40
- <option value="3">Option 3</option>
41
- <option value="4">Option 4</option>
42
- </optgroup>
43
- </select>
44
- <label>国</label>
45
- </div>
46
- </body>
45
+ <!--アイコン用-->
46
+ <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
47
+
48
+ <!--jQuery-->
49
+ <script
50
+ src="https://code.jquery.com/jquery-3.3.1.js"
51
+ integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
52
+ crossorigin="anonymous"></script>
47
53
 
54
+ <%= csrf_meta_tags %>
55
+ <%= csp_meta_tag %>
56
+
57
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
58
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
59
+ </head>
60
+
61
+ <body>
62
+ <nav class="white navigation">
63
+ <div class="nav-wrapper">
64
+ <a href="/" class="brand-logo green-text">Life Stamp Rally</a>
65
+ <ul class="right hide-on-med-and-down">
66
+ <li><a href="/stamps/new" class="waves-effect waves-light btn card-panel teal lighten-1"><i class="material-icons left">cloud_upload</i>Stamp!</a></li>
67
+ </ul>
68
+ </div>
69
+ </nav>
70
+
71
+ <%= yield %>
72
+ </body>
73
+ </html>
48
74
  ```
49
75
 
76
+ ```html
77
+ <!DOCTYPE html>
78
+ <!--ここがキャプチャの投稿画面です-->
79
+ <html>
80
+ <head>
81
+ <script src="new.js"></script>
82
+ </head>
83
+ <body>
84
+ <!--カード-->
85
+ <div class="col s12 m7">
86
+ <%= form_for @photo, :url => {:action => 'create'} do |f| %>
87
+ <h5 class="header">Let's STAMP the memory about your journey</h5>
88
+ <div class="card horizontal">
89
+ <div class="card-image">
90
+ <!--アップした写真を表示したい-->
91
+ <img src="http://butsuri.fun/wp-content/uploads/2018/04/757226.jpg">
92
+ </div>
93
+ <div class="card-stacked">
94
+ <div class="card-content">
95
+ <!--タイトル、そもそもいる?-->
96
+ <div class="row title">
97
+ <form class="col s12">
98
+ <div class="row">
99
+ <div class="input-field col s6">
100
+ <!--データ型変更しないと!-->
101
+ <input id="icon_prefix" type="text" name="title" class="validate">
102
+ <label for="icon_prefix">タイトル</label>
103
+ </div>
104
+ </div>
105
+ </form>
106
+ </div>
107
+
108
+ <!--国選択-->
109
+ <div class="input-field col s12 country-select">
110
+ <select>
111
+ <optgroup label="team 1">
112
+ <option value="1">Option 1</option>
113
+ <option value="2">Option 2</option>
114
+ </optgroup>
115
+ <optgroup label="team 2">
116
+ <option value="3">Option 3</option>
117
+ <option value="4">Option 4</option>
118
+ </optgroup>
119
+ </select>
120
+ <label>国</label>
121
+  </div>
122
+
123
+ <label class="field waves-effect waves-light btn card-panel teal lighten-1">
124
+ <a><i class="large material-icons left">camera_alt</i></a>
125
+ <div id="filename">
126
+   <%= f.file_field :photo, multiple: true, :value => "photo" %>
127
+  </div>
128
+ </label>
129
+ <textarea name="text" placeholder="メモ" rows="10" cols="30"></textarea>
130
+ </div>
131
+ <div class="card-action">
132
+ <input type="submit" value="Stamp!!">
133
+ </div>
134
+ </div>
135
+ </div>
136
+ <% end %>
137
+ </div>
138
+
139
+ </body>
140
+ </html>
141
+ ```
142
+
143
+ ```css
144
+ .col{
145
+ margin:0 auto;
146
+ }
147
+
148
+ .header{
149
+ text-align:center
150
+ }
151
+
152
+ .card{
153
+ margin:0 auto;
154
+ width:610px;
155
+ height:400px;
156
+ }
157
+
158
+ .card-image{
159
+ width:30%;
160
+ }
161
+
162
+ .card-content input{
163
+ width: 320px;
164
+ }
165
+
166
+ .card-content title{
167
+ display:block;
168
+ padding-bottom:20px;
169
+ }
170
+
171
+ .country-select{
172
+ display:block;
173
+ padding-bottom:50px;
174
+ }
175
+
176
+ .btn a{
177
+ color:white;
178
+ font-size: 1000px;
179
+ }
180
+
181
+ .btn i{
182
+ display:block;
183
+ margin:0 auto;
184
+ }
185
+
186
+ #filename{
187
+ display: none;
188
+ }
189
+ ```
190
+
50
191
  ```js
51
192
  document.addEventListener('DOMContentLoaded', function() {
52
193
  var elems = document.querySelectorAll('select');