質問編集履歴

4

コードの再提示

2019/09/15 05:24

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -86,11 +86,13 @@
86
86
 
87
87
  .fixed-bg {
88
88
 
89
+  word-wrap: break-word;
90
+
89
91
  min-height: 100vh;
90
92
 
91
93
  background-attachment: fixed;
92
94
 
93
- background-size: cover;
95
+ background-size: contain;
94
96
 
95
97
  background-position: center;
96
98
 
@@ -102,11 +104,9 @@
102
104
 
103
105
  background-image: url(170923.png);
104
106
 
105
- /*background-size: contain; */
107
+ background-size: contain;
106
108
 
107
- background-repeat: no-repeat;
109
+ background-repeat: no-repeat;
108
-
109
- background-size: contain;
110
110
 
111
111
  }
112
112
 
@@ -116,9 +116,7 @@
116
116
 
117
117
  background-image: url(7211.png);
118
118
 
119
- background-repeat: no-repeat;
120
-
121
- background-size: cover;
119
+ background-size: contain;
122
120
 
123
121
  }
124
122
 
@@ -128,9 +126,9 @@
128
126
 
129
127
  background-image: url(2377.png);
130
128
 
129
+ background-size: contain;
130
+
131
131
  background-repeat: no-repeat;
132
-
133
- background-size: cover;
134
132
 
135
133
  }
136
134
 

3

コードの提示

2019/09/15 05:24

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -12,13 +12,23 @@
12
12
 
13
13
  ```css
14
14
 
15
- background-size:cover
15
+ background-size:contain
16
16
 
17
17
  ```
18
18
 
19
19
  (縦横比を保持、表示領域全体を覆うように背景画像を表示する)
20
20
 
21
- 様にたら、何も表示されませんでした。
21
+ かし縦が余ってしまうので繰り返し表示されてしいました。
22
+
23
+
24
+
25
+ そこで、リピートを禁止する様に以下のコードを記入しました。
26
+
27
+ ```css
28
+
29
+ background-repeat: no-repeat;
30
+
31
+ ```
22
32
 
23
33
 
24
34
 

2

具体的化

2019/09/15 05:19

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,8 @@
1
1
  ### 実装内容
2
2
 
3
3
  html/cssを使って、スクロールすると、背景画像が切り替わる様なサイトをこの[サイト](https://takafumimegumi.com/demo/background-attachment/index.html)を参考にして作成しているのですが、スマホで見た際に、画像が拡大したものが表示され、全体の画像が表示されません。
4
+
5
+ なので、描画領域内に背景画像のすべてが表示されるよう拡大・縮小したいです。
4
6
 
5
7
 
6
8
 

1

コードの提示

2019/09/14 15:43

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -17,3 +17,157 @@
17
17
  (縦横比を保持、表示領域全体を覆うように背景画像を表示する)
18
18
 
19
19
  様にしたら、何も表示されませんでした。
20
+
21
+
22
+
23
+ ### 現在のコード
24
+
25
+ ```html
26
+
27
+ <div class="fixed-bg bg03 sentence">
28
+
29
+ <p>タイトル</p>
30
+
31
+ </div>
32
+
33
+
34
+
35
+ <div class="scroll-bg bg-color01" class="start">
36
+
37
+ <p style="background-color:#ffcc99;">説明文</p>
38
+
39
+ </div>
40
+
41
+ <div class="fixed-bg bg01 sentence">
42
+
43
+ <p>タイトル</p>
44
+
45
+ </div>
46
+
47
+
48
+
49
+ <div class="scroll-bg bg-color01" class="start">
50
+
51
+ <p style="background-color:#ffcc99;">説明文</p>
52
+
53
+ </div>
54
+
55
+
56
+
57
+ <div class="fixed-bg bg02 sentence">
58
+
59
+ <p>タイトル</p>
60
+
61
+ </div>
62
+
63
+
64
+
65
+ <div class="scroll-bg bg-color02">
66
+
67
+ <p style="background-color:#ffcc99;">説明文</p>
68
+
69
+ </div>
70
+
71
+ ```
72
+
73
+ ```css
74
+
75
+ .fixed-bg {
76
+
77
+ min-height: 100vh;
78
+
79
+ background-attachment: fixed;
80
+
81
+ background-size: cover;
82
+
83
+ background-position: center;
84
+
85
+ }
86
+
87
+
88
+
89
+ .bg01 {
90
+
91
+ background-image: url(170923.png);
92
+
93
+ /*background-size: contain; */
94
+
95
+ background-repeat: no-repeat;
96
+
97
+ background-size: contain;
98
+
99
+ }
100
+
101
+
102
+
103
+ .bg02 {
104
+
105
+ background-image: url(7211.png);
106
+
107
+ background-repeat: no-repeat;
108
+
109
+ background-size: cover;
110
+
111
+ }
112
+
113
+
114
+
115
+ .bg03 {
116
+
117
+ background-image: url(2377.png);
118
+
119
+ background-repeat: no-repeat;
120
+
121
+ background-size: cover;
122
+
123
+ }
124
+
125
+
126
+
127
+ .sentence{
128
+
129
+ position: relative;
130
+
131
+ }
132
+
133
+
134
+
135
+ .sentence p{
136
+
137
+ position: absolute;
138
+
139
+ top: 50%;
140
+
141
+ left: 50%;
142
+
143
+ -ms-transform: translate(-50%,-50%);
144
+
145
+ -webkit-transform: translate(-50%,-50%);
146
+
147
+ transform: translate(-50%,-50%);
148
+
149
+ margin:0;
150
+
151
+ padding:0;
152
+
153
+ color: white;/*文字は白に*/
154
+
155
+ font-weight: bold; /*太字に*/
156
+
157
+ font-size: 2em;/*サイズ2倍*/
158
+
159
+ font-family :Quicksand, sans-serif;/*Google Font*/
160
+
161
+ }
162
+
163
+
164
+
165
+ .sentence img{
166
+
167
+ width: 100%;
168
+
169
+ }
170
+
171
+
172
+
173
+ ```