Jump to content
  • 0

Slider


Sider
 Share

Question

Всем привет.Не так давно начал изучать верстку.И кароче захотел создать слайдер на основе html css без js.

Застрял булеты работают и стрелки также но только стрелки становяться видимы когда первый раз нажал на булет.До этого их никак немогу настроить.

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .wrapper{
            width: 700px;
            height: 400px;
            margin:0 auto;
            border:5px solid green;
            border-radius: 20px;
            overflow: hidden;
            position: relative;
        }
        .container{
            width: 600px;
            height: 300px;
            border: 5px solid green;
            border-radius: 20px;
            margin: 20px auto;
        }
        .slider__items{
            display: none;
        }
        .bullets{
            display: flex;
            position: absolute;
            left:100px;
            bottom:30px;
        }
        .bullets__items{
            width: 50px;
            height: 15px;
            border:2px solid green;
            border-radius: 20px;
            background-color: lightgreen;
            margin: 0 20px;
        }
   
        .images{
            display: flex;
        }
        .images__items{
            width: 600px;
            height: 300px;
            border-radius: 20px;
            margin-right: 55px;
        }
     
        .arrows__prev{
            background-image: url(./img/next.png);
            background-size: contain;
            width: 40px;
            height: 40px;
            position: absolute;
            top:150px;
            left: 2px;
        }
        #slide1:checked ~ .images .image1{
            margin-left: 0;
        }
        #slide2:checked ~ .images .image2{
            margin-left: -655px;
        }
        #slide3:checked ~ .images .image3{
            margin-left: -1310px;
        }
        #slide4:checked ~ .images .image4{
            margin-left: -1965px;
        }
        #slide5:checked ~ .images .image5{
            margin-left: -2620px;
        }
        #slide1:checked ~ .arrow__next .img2,
        #slide2:checked ~ .arrow__next .img3,
        #slide3:checked ~ .arrow__next .img4,
        #slide4:checked ~ .arrow__next .img5,
        #slide5:checked ~ .arrow__next .img1{
            display: block;
            background-image: url(./img/next.png);
            background-size: contain;
            width: 40px;
            height: 40px;
            position: absolute;
            top:150px;
            right: 2px;
       
        }
        #slide1:checked ~ .arrow__prev .img5,
        #slide2:checked ~ .arrow__prev .img1,
        #slide3:checked ~ .arrow__prev .img2,
        #slide4:checked ~ .arrow__prev .img3,
        #slide5:checked ~ .arrow__prev .img4
        {
            display: block;
            background-image: url(./img/prev.png);
            background-size: contain;
            width: 40px;
            height: 40px;
            position: absolute;
            top:150px;
            left: 2px;
       
        }

    </style>
</head>
<body>
    <div class="wrapper">
        <div class="container">
            <div class="slider">
                <input type="radio" name="slider" class="slider__items" id="slide1">
                <input type="radio" name="slider" class="slider__items" id="slide2">
                <input type="radio" name="slider" class="slider__items" id="slide3">
                <input type="radio" name="slider" class="slider__items" id="slide4">
                <input type="radio" name="slider" class="slider__items" id="slide5">
               
                <div class="bullets">
                    <label for="slide1" class="bullets__items"></label>
                    <label for="slide2" class="bullets__items"></label>
                    <label for="slide3" class="bullets__items"></label>
                    <label for="slide4" class="bullets__items"></label>
                    <label for="slide5" class="bullets__items"></label>
                </div>
                <div class="arrow__next">
                    <label for="slide1" class="arrows__item img1"></label>
                    <label for="slide2" class="arrows__item img2"></label>
                    <label for="slide3" class="arrows__item img3"></label>
                    <label for="slide4" class="arrows__item img4"></label>
                    <label for="slide5" class="arrows__item img5"></label>
                </div>
                <div class="arrow__prev">
                    <label for="slide1" class="arrows__item img1"></label>
                    <label for="slide2" class="arrows__item img2"></label>
                    <label for="slide3" class="arrows__item img3"></label>
                    <label for="slide4" class="arrows__item img4"></label>
                    <label for="slide5" class="arrows__item img5"></label>
                </div>
                <div class="images">
                    <img src="./img/1.jpg" alt="" class="images__items image1">
                    <img src="./img/2.jpg" alt="" class="images__items image2">
                    <img src="./img/3.jpg" alt="" class="images__items image3">
                    <img src="./img/4.jpg" alt="" class="images__items image4">
                    <img src="./img/5.jpg" alt="" class="images__items image5">
                </div>
            </div>
        </div>
    </div>
</body>
</html>
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Обсуждения

    • Актуальные контакты: Telegram: @Nikker_web E-Mail:   tarasevich.email@gmail.com Портфолио https://www.behance.net/d4d4186e Разрабатываю дизайн групп в соц сетях, сайтов, приложений, другой дизайн под заказ    
    • Актуальные контакты: Telegram: @Nikker_web E-Mail:   tarasevich.email@gmail.com   Разрабатываю дизайн групп в соц сетях, сайтов, приложений, другой дизайн под заказ   Портфолио https://www.behance.net/d4d4186e
    • Доброго всем времени суток. Прошу помощи. Научите принципу изменения футера. Движок Xenforo. Версия 2.2.10. Стиль дефолтный. Что именно нужно в итоге на фото примере. Мой шаблон app.footer less имеет следующее значение.  .p-footer { .xf-publicFooter(); a { .xf-publicFooterLink(); } } .p-footer-inner { .m-pageWidth(); .m-pageInset(); padding-top: @xf-paddingMedium; padding-bottom: @xf-paddingLarge; } .p-footer-row { .m-clearFix(); margin-bottom: -@xf-paddingLarge; } .p-footer-row-main { float: left; margin-bottom: @xf-paddingLarge; } .p-footer-row-opposite { float: right; margin-bottom: @xf-paddingLarge; } .p-footer-linkList { .m-listPlain(); .m-clearFix(); > li { float: left; margin-right: .5em; &:last-child { margin-right: 0; } a { padding: 2px 4px; border-radius: @xf-borderRadiusSmall; &:hover { text-decoration: none; background-color: fade(@xf-publicFooterLink--color, 10%); } } } } .p-footer-rssLink { > span { position: relative; top: -1px; display: inline-block; width: 1.44em; height: 1.44em; line-height: 1.44em; text-align: center; font-size: .8em; background-color: #4682B4; border-radius: 2px; } .fa-rss { color: white; } } .p-footer-copyright { margin-top: @xf-elementSpacer; text-align: center; font-size: @xf-fontSizeSmallest; } .p-footer-debug { margin-top: @xf-paddingLarge; text-align: right; font-size: @xf-fontSizeSmallest; .pairs > dt { color: inherit; } } @media (max-width: @xf-responsiveMedium) { .p-footer-row-main, .p-footer-row-opposite { float: none; } .p-footer-copyright { text-align: left; padding: 0 4px; // aligns with other links } }  
    • Нужны сайты с примерами верстки, типа https://css-tricks.com/. Типовые приемы и нестандартные на все случаи жизни. Накидайте ссылок.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy