68130


[動くCSSのためのメモスライドショー](https://lopan.jp/css-animation-
slideshow/)を参考にして、スライドショーを作成しました。  
動くようになったのですが、もう少し手を加えたくて投稿しました。

やりたいこと

・次の画像に遷移するためのボタンを透明化して、画像を両サイドいっぱいにしたい。  
-今はlightSeaGreenが設定されているので、そこを透明にするのはできるのですが、画像が思うように両サイドいっぱいにならないで困ってます。  
・高さをもう少し短くしたい。どの部分を変更すれば高さの調節ができますでしょうか。

よろしくお願いします。  

[code]

    @charset "utf-8";
    
    .slideshow {
    position: relative;
    overflow: hidden;
    }
    input[name="slideshow"] {
    display: none;
    }
    
    /* :::::: slideContents :::::: */
    .slideContents {
    position: relative;
    background: lightSeaGreen;
    text-align: center;
    -webkit-user-select: none;
    user-select: none;
    transition: transform .6s;
    }
    .slideContents section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    transform: translateX(100%);
    transition: transform .6s cubic-bezier(0.215, 0.61, 0.355, 1);
    }
    .slideContents section img {
    max-width: 100%;
    padding: 0 50px;
    box-sizing: border-box;
    vertical-align: middle;
    }
    
    /* :::::: arrows :::::: */
    .arrow,
    .arrow label,
    .arrow .ico {
    position: absolute;
    }
    .arrow {
    top: 0;
    margin: 0;
    transition: background .3s;
    }
    .prev {
    left: 0;
    }
    .next {
    right: 0;
    }
    .arrow:hover {
    background: rgba(255,255,255,.2);
    }
    .arrow,
    .arrow label {
    cursor: pointer;
    width: 50px;
    height: 100%;
    }
    .arrow label {
    top: 0;
    left: 0;
    z-index: 1;
    }
    .arrow .ico {
    top: calc(50% - 6px);
    width: 12px;
    height: 12px;
    border-top: 3px solid #fff;
    opacity: 0;
    }
    .prev .ico {
    left: 50%;
    border-left: 3px solid #fff;
    transform: rotate(-45deg);
    transition: left .3s cubic-bezier(0.215, 0.61, 0.355, 1), opacity .3s;
    }
    .next .ico {
    right: 50%;
    border-right: 3px solid #fff;
    transform: rotate(45deg);
    transition: right .3s cubic-bezier(0.215, 0.61, 0.355, 1), opacity .3s;
    }
    .arrow:hover .ico {
    opacity: .6;
    }
    .prev:hover .ico {
    left: calc(50% - 6px);
    }
    .next:hover .ico {
    right: calc(50% - 6px);
    }
    
    /* :::::: mechanism :::::: */
    #switch1:checked ~ .slideContents #slide1,
    #switch2:checked ~ .slideContents #slide2,
    #switch3:checked ~ .slideContents #slide3,
    #switch4:checked ~ .slideContents #slide4,
    #switch5:checked ~ .slideContents #slide5 {
    position: relative;
    transform: none;
    }
    #switch1:checked ~ .slideContents #slide5,
    #switch1:checked ~ .slideContents #slide4,
    #switch2:checked ~ .slideContents #slide1,
    #switch2:checked ~ .slideContents #slide5,
    #switch3:checked ~ .slideContents #slide2,
    #switch3:checked ~ .slideContents #slide1,
    #switch4:checked ~ .slideContents #slide3,
    #switch4:checked ~ .slideContents #slide2,
    #switch5:checked ~ .slideContents #slide4,
    #switch5:checked ~ .slideContents #slide3 {
    transform: translateX(-100%);
    }
    #switch1:checked ~ .slideContents #slide3,
    #switch1:checked ~ .slideContents #slide4,
    #switch2:checked ~ .slideContents #slide4,
    #switch2:checked ~ .slideContents #slide5,
    #switch3:checked ~ .slideContents #slide5,
    #switch3:checked ~ .slideContents #slide1,
    #switch4:checked ~ .slideContents #slide1,
    #switch4:checked ~ .slideContents #slide2,
    #switch5:checked ~ .slideContents #slide2,
    #switch5:checked ~ .slideContents #slide3 {
    transition-duration: 0s;
    }
    
    /* :::::: arrow mechanism :::::: */
    .arrow label {
    pointer-events: none;
    }
    #switch1:checked ~ .prev label[for="switch5"],
    #switch2:checked ~ .prev label[for="switch1"],
    #switch3:checked ~ .prev label[for="switch2"],
    #switch4:checked ~ .prev label[for="switch3"],
    #switch5:checked ~ .prev label[for="switch4"],
    #switch1:checked ~ .next label[for="switch2"],
    #switch2:checked ~ .next label[for="switch3"],
    #switch3:checked ~ .next label[for="switch4"],
    #switch4:checked ~ .next label[for="switch5"],
    #switch5:checked ~ .next label[for="switch1"] {
    pointer-events: auto;
    }
[/code]

[code]

    <!doctype html>
    <html lang="ja">
    
    <meta charset="utf-8">
    <body>
    <div class="slideshow">
    <input type="radio" name="slideshow" id="switch1" checked>
    <input type="radio" name="slideshow" id="switch2">
    <input type="radio" name="slideshow" id="switch3">
    <input type="radio" name="slideshow" id="switch4">
    <input type="radio" name="slideshow" id="switch5">
    <div class="slideContents">
        <section id="slide1">
            <img src="https://cdn.pixabay.com/photo/2020/04/24/10/23/pier-5086290_1280.jpg">
        </section>
        <section id="slide2">
            <img src="https://cdn.pixabay.com/photo/2020/06/02/07/51/luka-5249892_1280.jpg">
        </section>
        <section id="slide3">
            <img src="https://cdn.pixabay.com/photo/2020/04/13/17/16/netherlands-5039354_1280.jpg">
        </section>
        <section id="slide4">
            <img src="https://cdn.pixabay.com/photo/2020/04/15/12/09/summer-5046401_1280.jpg">
        </section>
        <section id="slide5">
            <img src="https://cdn.pixabay.com/photo/2020/04/11/20/35/lighthouse-5031977_1280.jpg">
        </section>
    </div>
    <p class="arrow prev">
        <i class="ico"></i>
        <label for="switch1"></label>
        <label for="switch2"></label>
        <label for="switch3"></label>
        <label for="switch4"></label>
        <label for="switch5"></label>
    </p>
    <p class="arrow next">
        <i class="ico"></i>
        <label for="switch1"></label>
        <label for="switch2"></label>
        <label for="switch3"></label>
        <label for="switch4"></label>
        <label for="switch5"></label>
    </p>
    </div>
    
    
    </body>
    </html>
[/code]


CC BY-SA 4.0
2020-06-29T23:40:48.387
68124
2020-06-30T02:38:30.437
40597
question
html css
CSS スライドショーを完成させたい。


> 今はlightSeaGreenが設定されているので、そこを透明にするのはできるのですが、画像が思うように両サイドいっぱいにならないで困ってます。

imgにpaddingがついてますね。こちらを外せば問題ないかと

> ・高さをもう少し短くしたい。どの部分を変更すれば高さの調節ができますでしょうか。

slideContents に高さを設定すればよろしいと思います。

CSSの調整についてですが  
CSSを試すにはChromeのF12のElementsタブでStyleなどを利用してCSSを動的にいじるとわかりやすいと思います。直接スタイルを変更したり、paddingをなくしたりといった操作が動的に対応ができます。  
一度お試しを。

[code]

    @charset "utf-8";
    
    .slideshow {
    position: relative;
    overflow: hidden;
    }
    input[name="slideshow"] {
    display: none;
    }
    
    /* :::::: slideContents :::::: */
    .slideContents {
    position: relative;
    background: lightSeaGreen;
    text-align: center;
    -webkit-user-select: none;
    user-select: none;
    transition: transform .6s;
    height: 200px;
    }
    .slideContents section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    transform: translateX(100%);
    transition: transform .6s cubic-bezier(0.215, 0.61, 0.355, 1);
    }
    .slideContents section img {
    max-width: 100%;
    padding: 0 0px;
    box-sizing: border-box;
    vertical-align: middle;
    height: -webkit-fill-available;
    width: fit-content;
    }
    
    /* :::::: arrows :::::: */
    .arrow,
    .arrow label,
    .arrow .ico {
    position: absolute;
    }
    .arrow {
    top: 0;
    margin: 0;
    transition: background .3s;
    }
    .prev {
    left: 0;
    }
    .next {
    right: 0;
    }
    .arrow:hover {
    background: rgba(255,255,255,.2);
    }
    .arrow,
    .arrow label {
    cursor: pointer;
    width: 50px;
    height: 100%;
    }
    .arrow label {
    top: 0;
    left: 0;
    z-index: 1;
    }
    .arrow .ico {
    top: calc(50% - 6px);
    width: 12px;
    height: 12px;
    border-top: 3px solid #fff;
    opacity: 0;
    }
    .prev .ico {
    left: 50%;
    border-left: 3px solid #fff;
    transform: rotate(-45deg);
    transition: left .3s cubic-bezier(0.215, 0.61, 0.355, 1), opacity .3s;
    }
    .next .ico {
    right: 50%;
    border-right: 3px solid #fff;
    transform: rotate(45deg);
    transition: right .3s cubic-bezier(0.215, 0.61, 0.355, 1), opacity .3s;
    }
    .arrow:hover .ico {
    opacity: .6;
    }
    .prev:hover .ico {
    left: calc(50% - 6px);
    }
    .next:hover .ico {
    right: calc(50% - 6px);
    }
    
    /* :::::: mechanism :::::: */
    #switch1:checked ~ .slideContents #slide1,
    #switch2:checked ~ .slideContents #slide2,
    #switch3:checked ~ .slideContents #slide3,
    #switch4:checked ~ .slideContents #slide4,
    #switch5:checked ~ .slideContents #slide5 {
    position: relative;
    transform: none;
    }
    #switch1:checked ~ .slideContents #slide5,
    #switch1:checked ~ .slideContents #slide4,
    #switch2:checked ~ .slideContents #slide1,
    #switch2:checked ~ .slideContents #slide5,
    #switch3:checked ~ .slideContents #slide2,
    #switch3:checked ~ .slideContents #slide1,
    #switch4:checked ~ .slideContents #slide3,
    #switch4:checked ~ .slideContents #slide2,
    #switch5:checked ~ .slideContents #slide4,
    #switch5:checked ~ .slideContents #slide3 {
    transform: translateX(-100%);
    }
    #switch1:checked ~ .slideContents #slide3,
    #switch1:checked ~ .slideContents #slide4,
    #switch2:checked ~ .slideContents #slide4,
    #switch2:checked ~ .slideContents #slide5,
    #switch3:checked ~ .slideContents #slide5,
    #switch3:checked ~ .slideContents #slide1,
    #switch4:checked ~ .slideContents #slide1,
    #switch4:checked ~ .slideContents #slide2,
    #switch5:checked ~ .slideContents #slide2,
    #switch5:checked ~ .slideContents #slide3 {
    transition-duration: 0s;
    }
    
    /* :::::: arrow mechanism :::::: */
    .arrow label {
    pointer-events: none;
    }
    #switch1:checked ~ .prev label[for="switch5"],
    #switch2:checked ~ .prev label[for="switch1"],
    #switch3:checked ~ .prev label[for="switch2"],
    #switch4:checked ~ .prev label[for="switch3"],
    #switch5:checked ~ .prev label[for="switch4"],
    #switch1:checked ~ .next label[for="switch2"],
    #switch2:checked ~ .next label[for="switch3"],
    #switch3:checked ~ .next label[for="switch4"],
    #switch4:checked ~ .next label[for="switch5"],
    #switch5:checked ~ .next label[for="switch1"] {
    pointer-events: auto;
    }
[/code]

[code]

    <!doctype html>
    <html lang="ja">
    
    <meta charset="utf-8">
    <body>
    <div class="slideshow">
    <input type="radio" name="slideshow" id="switch1" checked>
    <input type="radio" name="slideshow" id="switch2">
    <input type="radio" name="slideshow" id="switch3">
    <input type="radio" name="slideshow" id="switch4">
    <input type="radio" name="slideshow" id="switch5">
    <div class="slideContents">
        <section id="slide1">
            <img src="https://cdn.pixabay.com/photo/2020/04/24/10/23/pier-5086290_1280.jpg">
        </section>
        <section id="slide2">
            <img src="https://cdn.pixabay.com/photo/2020/06/02/07/51/luka-5249892_1280.jpg">
        </section>
        <section id="slide3">
            <img src="https://cdn.pixabay.com/photo/2020/04/13/17/16/netherlands-5039354_1280.jpg">
        </section>
        <section id="slide4">
            <img src="https://cdn.pixabay.com/photo/2020/04/15/12/09/summer-5046401_1280.jpg">
        </section>
        <section id="slide5">
            <img src="https://cdn.pixabay.com/photo/2020/04/11/20/35/lighthouse-5031977_1280.jpg">
        </section>
    </div>
    <p class="arrow prev">
        <i class="ico"></i>
        <label for="switch1"></label>
        <label for="switch2"></label>
        <label for="switch3"></label>
        <label for="switch4"></label>
        <label for="switch5"></label>
    </p>
    <p class="arrow next">
        <i class="ico"></i>
        <label for="switch1"></label>
        <label for="switch2"></label>
        <label for="switch3"></label>
        <label for="switch4"></label>
        <label for="switch5"></label>
    </p>
    </div>
    
    
    </body>
    </html>
[/code]


CC BY-SA 4.0
2020-06-30T01:27:20.630
68130
2020-06-30T02:38:30.437
2020-06-30T02:38:30.437
22665
22665
68124
answer