java scriptやjQueryなどを使わずに画像のスライドショーを設置したく、ネットで調べて下記のように出来上がり、設置しました。
サイトの横幅を指定するPCサイトでは問題なかったのですが、divの高さを指定しないといけないため、レスポンシブデザインでは、画面幅によって次にくる要素と離れすぎたりかぶったりしてしまいますので、使用できません。
レスポンシブにも対応できるようにするためには、どこをどう改変すれば良いでしょうか?
もしくは方法を大きく変えないとダメでしょうか?
初心者ですみませんが、教えてください。よろしくお願いいたします。
(html)
<div class="photo_show"> <img src="../images/1.jpg"> <img src="../images/2.jpg"> <img src="../images/3.jpg"> <img src="../images/4.jpg"> </div>
(css)
.photo_show { height: 400px; width: 100%; /*max-width: 480px;*/ position: relative; margin: auto; } .photo_show img { animation: show 20s infinite; -webkit-animation: show 20s infinite; height: auto; max-width: 100%; width: 100%; opacity: 0; position: absolute; } /*アニメーション*/ @keyframes show { 0% {opacity:0} 10% {opacity:1} 20% {opacity:1} 50% {opacity:0} } @-webkit-keyframes show { 0% {opacity:0} 10% {opacity:1} 20% {opacity:1} 50% {opacity:0} } /*各画像のアニメーションの開始時間をずらす*/ .photo_show img:nth-of-type(1) { animation-delay: 0s; -webkit-animation-delay: 0s; } .photo_show img:nth-of-type(2) { animation-delay: 5s; -webkit-animation-delay: 5s; } .photo_show img:nth-of-type(3) { animation-delay: 10s; -webkit-animation-delay: 10s; } .photo_show img:nth-of-type(4) { animation-delay: 15s; -webkit-animation-delay: 15s; }
回答1件
あなたの回答
tips
プレビュー