前提・実現したいこと
コーディング初学者です。質問お願いします
BOXの真ん中の文字が画面を縮小してもコンテンツからはみ出す事無く真ん中のまま縮小したいのですが
画面幅を縮小していった際に途中で文字が飛び出してしまいます。
この見た目のまま縮小したいのですが
このように文字が飛び出していってしまいます
どなたか解決法を教えてください
発生している問題・エラーメッセージ
画面幅を縮小していくと文字がボックスから飛び出してしまいます。
該当のソースコード
HTML5
1<div class="wrapper"> 2 <ul class="main_portfolio"> 3 <li> 4 <div class="first"></div> 5 <div class="second"></div> 6 <div class="third"></div> 7 <p class="txt">p</p> 8 </li> 9 <li>O</li> 10 <li> 11 <div class="first1"></div> 12 <div class="second1"></div> 13 <div class="third1"></div> 14 <p class="txt1">R</p> 15 </li> 16 <li>T</li> 17 <li>●</li> 18 <li>F</li> 19 <li><div class="first2"></div> 20 <div class="second2"></div> 21 <div class="third2"></div> 22 <p class="txt2">O</p></li> 23 <li>L</li> 24 <li> 25 <div class="first3"></div> 26 <div class="second3"></div> 27 <div class="third3"></div> 28 <p class="txt3">I</p> 29 </li> 30 <li>O</li> 31 </ul> 32</div> 33 34ソースコード 35
css
1.wrapper{ 2 max-width: 1160px; 3} 4.main_portfolio { 5 padding: 36px 0 20% 81px; 6 display: flex; 7 flex-wrap: wrap; 8 justify-content: space-between; 9 max-width: 858px; 10} 11.main_portfolio li { 12 width: 17%; 13 max-width: 147px; 14 max-height: 166px; 15 font-family: 'Arial Black', Gadget, 'sans-serif'; 16 font-size: 968%; 17 text-align: center; 18 border: 1px solid #000000; 19 margin-bottom: 26px; 20 position: relative; 21 z-index: 1; 22 overflow: hidden; 23} 24/*ポートフォリオ 背景設定*/ 25.first, 26 .second, 27 .third { 28 height: 166px; 29 width: 100%; 30 } 31.first, 32 .second, 33 .third { 34 position: absolute; 35 } 36.second, 37 .third { 38 opacity: 0; 39 } 40.first { 41 animation: first 5s infinite; 42 background: linear-gradient(#ff8989, #ff8989); 43 z-index: 10; 44 } 45 @keyframes first { 46 0% {opacity: 1.0;} 47 10% {opacity: 0.8;} 48 20% {opacity: 0.6;} 49 30% {opacity: 0.4;} 50 40% {opacity: 0.2;} 51 50% {opacity: 0.1;} 52 60% {opacity: 0.2;} 53 70% {opacity: 0.4;} 54 80% {opacity: 0.6;} 55 90% {opacity: 0.8;} 56 100% {opacity: 1.0;} 57 } 58.second { 59 animation: second 5s infinite; animation-delay: 2s; 60 background: linear-gradient(#ffadad, #ffadad); 61 z-index: 20; 62 } 63 @keyframes second { 64 0% {opacity: 0;} 65 10% {opacity: 0.2;} 66 20% {opacity: 0.4;} 67 30% {opacity: 0.6;} 68 40% {opacity: 0.8;} 69 50% {opacity: 1.0;} 70 60% {opacity: 0.8;} 71 70% {opacity: 0.6;} 72 80% {opacity: 0.4;} 73 90% {opacity: 0.2;} 74 100% {opacity: 0;} 75 } 76 77 .third { 78 animation: third 5s infinite; 79 animation-delay: 8s; 80 background: linear-gradient(#ffd6d6, #ffd6d6); 81 z-index: 30; 82 } 83 @keyframes third { 84 0% {opacity: 0;} 85 10% {opacity: 0.2;} 86 20% {opacity: 0.4;} 87 30% {opacity: 0.6;} 88 40% {opacity: 0.8;} 89 50% {opacity: 1.0;} 90 60% {opacity: 0.8;} 91 70% {opacity: 0.6;} 92 80% {opacity: 0.4;} 93 90% {opacity: 0.2;} 94 100% {opacity: 0;} 95 } 96.txt {; 97 position: absolute; 98 width: 100%; 99 z-index: 1000; 100 top:-28px; 101 } 102.first1, 103 .second1, 104 .third1 { 105 height: 166px; 106 width: 100%; 107 } 108.first1, 109 .second1, 110 .third1 { 111 position: absolute; 112 } 113.second1, 114 .third1 { 115 opacity: 0; 116 } 117.first1 { 118 animation: first 5s infinite; 119 background: linear-gradient(#c4ff89,#c4ff89); 120 z-index: 10; 121 } 122 @keyframes first1 { 123 0% {opacity: 1.0;} 124 10% {opacity: 0.8;} 125 20% {opacity: 0.6;} 126 30% {opacity: 0.4;} 127 40% {opacity: 0.2;} 128 50% {opacity: 0.1;} 129 60% {opacity: 0.2;} 130 70% {opacity: 0.4;} 131 80% {opacity: 0.6;} 132 90% {opacity: 0.8;} 133 100% {opacity: 1.0;} 134 } 135.second1 { 136 animation: second 5s infinite; animation-delay: 2s; 137 background: linear-gradient(#d1ffa3, #d1ffa3); 138 z-index: 20; 139 } 140 @keyframes second1 { 141 0% {opacity: 0;} 142 10% {opacity: 0.2;} 143 20% {opacity: 0.4;} 144 30% {opacity: 0.6;} 145 40% {opacity: 0.8;} 146 50% {opacity: 1.0;} 147 60% {opacity: 0.8;} 148 70% {opacity: 0.6;} 149 80% {opacity: 0.4;} 150 90% {opacity: 0.2;} 151 100% {opacity: 0;} 152 } 153 154 .third1 { 155 animation: third 5s infinite; 156 animation-delay: 8s; 157 background: linear-gradient(#edffdb,#edffdb); 158 z-index: 30; 159 } 160 @keyframes third1 { 161 0% {opacity: 0;} 162 10% {opacity: 0.2;} 163 20% {opacity: 0.4;} 164 30% {opacity: 0.6;} 165 40% {opacity: 0.8;} 166 50% {opacity: 1.0;} 167 60% {opacity: 0.8;} 168 70% {opacity: 0.6;} 169 80% {opacity: 0.4;} 170 90% {opacity: 0.2;} 171 100% {opacity: 0;} 172 } 173.txt1 {; 174 position: absolute; 175 width: 100%; 176 z-index: 1000; 177 top:0px; 178 } 179/*Oのcss*/ 180.first2, 181 .second2, 182 .third2 { 183 height: 166px; 184 width: 100%; 185 } 186.first2, 187 .second2, 188 .third2 { 189 position: absolute; 190 } 191.second2, 192 .third2 { 193 opacity: 0; 194 } 195.first2 { 196 animation: first 5s infinite; 197 background: linear-gradient(#89c4ff,#89c4ff); 198 z-index: 10; 199 } 200 @keyframes first2 { 201 0% {opacity: 1.0;} 202 10% {opacity: 0.8;} 203 20% {opacity: 0.6;} 204 30% {opacity: 0.4;} 205 40% {opacity: 0.2;} 206 50% {opacity: 0.1;} 207 60% {opacity: 0.2;} 208 70% {opacity: 0.4;} 209 80% {opacity: 0.6;} 210 90% {opacity: 0.8;} 211 100% {opacity: 1.0;} 212 } 213.second2 { 214 animation: second 5s infinite; animation-delay: 2s; 215 background: linear-gradient(#a8d3ff, #a8d3ff); 216 z-index: 20; 217 } 218 @keyframes second2 { 219 0% {opacity: 0;} 220 10% {opacity: 0.2;} 221 20% {opacity: 0.4;} 222 30% {opacity: 0.6;} 223 40% {opacity: 0.8;} 224 50% {opacity: 1.0;} 225 60% {opacity: 0.8;} 226 70% {opacity: 0.6;} 227 80% {opacity: 0.4;} 228 90% {opacity: 0.2;} 229 100% {opacity: 0;} 230 } 231 232 .third2 { 233 animation: third 5s infinite; 234 animation-delay: 8s; 235 background: linear-gradient(#d6eaff,#d6eaff); 236 z-index: 30; 237 } 238 @keyframes third2 { 239 0% {opacity: 0;} 240 10% {opacity: 0.2;} 241 20% {opacity: 0.4;} 242 30% {opacity: 0.6;} 243 40% {opacity: 0.8;} 244 50% {opacity: 1.0;} 245 60% {opacity: 0.8;} 246 70% {opacity: 0.6;} 247 80% {opacity: 0.4;} 248 90% {opacity: 0.2;} 249 100% {opacity: 0;} 250 } 251.txt2 {; 252 position: absolute; 253 width: 100%; 254 z-index: 1000; 255 top:0px; 256 } 257/**/ 258.first3, 259 .second3, 260 .third3 { 261 height: 166px; 262 width: 100%; 263 } 264.first3, 265 .second3, 266 .third3 { 267 position: absolute; 268 } 269.second3, 270 .third3 { 271 opacity: 0; 272 } 273.first3 { 274 animation: first 3s infinite; 275 background: linear-gradient(#ffff84,#ffff84); 276 z-index: 10; 277 } 278 @keyframes first3 { 279 0% {opacity: 1.0;} 280 10% {opacity: 0.8;} 281 20% {opacity: 0.6;} 282 30% {opacity: 0.4;} 283 40% {opacity: 0.2;} 284 50% {opacity: 0.1;} 285 60% {opacity: 0.2;} 286 70% {opacity: 0.4;} 287 80% {opacity: 0.6;} 288 90% {opacity: 0.8;} 289 100% {opacity: 1.0;} 290 } 291.second3 { 292 animation: second 3s infinite; animation-delay: 2s; 293 background: linear-gradient(#ffffad, #ffffad); 294 z-index: 20; 295 } 296 @keyframes second3 { 297 0% {opacity: 0;} 298 10% {opacity: 0.2;} 299 20% {opacity: 0.4;} 300 30% {opacity: 0.6;} 301 40% {opacity: 0.8;} 302 50% {opacity: 1.0;} 303 60% {opacity: 0.8;} 304 70% {opacity: 0.6;} 305 80% {opacity: 0.4;} 306 90% {opacity: 0.2;} 307 100% {opacity: 0;} 308 } 309 310 .third3 { 311 animation: third 3s infinite; 312 animation-delay: 8s; 313 background: linear-gradient(#ffffcc,#ffffcc); 314 z-index: 30; 315 } 316 @keyframes third3 { 317 0% {opacity: 0;} 318 10% {opacity: 0.2;} 319 20% {opacity: 0.4;} 320 30% {opacity: 0.6;} 321 40% {opacity: 0.8;} 322 50% {opacity: 1.0;} 323 60% {opacity: 0.8;} 324 70% {opacity: 0.6;} 325 80% {opacity: 0.4;} 326 90% {opacity: 0.2;} 327 100% {opacity: 0;} 328 } 329.txt3 {; 330 position: absolute; 331 width: 100%; 332 z-index: 1000; 333 top:0px; 334 } 335/*ここまでポートフォリオ 背景設定*/ 336 337.main_portfolio li:nth-child(3){ 338 background: #a5d4ad; 339} 340.main_portfolio li:nth-child(7){ 341 background: #9fd9f6; 342} 343.main_portfolio li:nth-child(9){ 344 background: #fff9b1; 345} 346.main_portfolio li:nth-child(5){ 347 position: relative; 348}
試したこと
いろいろ試しましたがどうしても解決できませんでした
補足情報(FW/ツールのバージョンなど)
背景にアニメーションを使ってましてCSSのコードがかなり長く見づらくなっていてお手数お掛け致します。
回答1件
あなたの回答
tips
プレビュー