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

質問編集履歴

1

HTML/cssを追記しました。

2021/01/19 01:30

投稿

shibaco
shibaco

スコア18

title CHANGED
File without changes
body CHANGED
@@ -11,7 +11,44 @@
11
11
  inputボタンに疑似クラス::beforeをつけ、ボタンを作成しました。
12
12
  しかし、デフォルトの[ファイルを選択]の表示が邪魔で、ボタンとかぶったり、marginなどで調整しますが次は[選択されていません]がボタンで隠れてしまうなど、デザイン調整が難しく、非表示にしたいです。
13
13
 
14
+ ```HTML
15
+ <div class="view_box">
16
+ <span class="wpcf7-form-control-wrap upload-file">
17
+ <input type="file" name="upload-file" size="40" class="wpcf7-form-control wpcf7-file file-upload_input" id="myImage" accept=".gif,.png,.jpg,.jpeg" aria-invalid="false" /></span>
18
+ </div>
19
+ ```
14
20
 
21
+ ```scss
22
+ .file-upload_input {
23
+ outline: none;
24
+ margin-left: 18%;
25
+ &::before {
26
+ width: 180px;
27
+ height: 51px;
28
+ transition: all 0.3s;
29
+ background-image: -webkit-gradient(
30
+ linear,
31
+ left top,
32
+ right top,
33
+ from(#F7D441),
34
+ color-stop(50%, #BDA029),
35
+ to(#6A5910)
36
+ );
37
+ background-image: -webkit-linear-gradient(left, #F7D441, #BDA029 50%, #6A5910);
38
+ background-image: linear-gradient(90deg, #F7D441, #BDA029 50%, #6A5910);
39
+ border-radius: 4px;
40
+ content: 'ファイルを選択';
41
+ font-size: 14px;
42
+ left: 0;
43
+ position: absolute;
44
+ top: -12px;
45
+ line-height: 51px;
46
+ text-align: center;
47
+ }
48
+ }
49
+ ```
50
+
51
+
15
52
  試した動作
16
53
  ```css
17
54
  input#file-upload-button {