oguhpereira
11/22/2018 - 6:43 PM

List Toggle with input and pure CSS

List Toggle with input and pure CSS

.list-toggle {
    padding-left: 0px;
    list-style: none;
    .toggle-link {
        color: #252525;
        background: #e5e5e5;
        width: 100%;
        display: inline-block;
        font-size: 1.3em;
        padding-bottom: 15px;
        padding-top: 15px;
        padding-left: 15px;
        position: relative;
        margin-bottom: 2px;
        &::after {
            content: "+";
            padding-right: 10px;
            display: inline-block;
            position: absolute;
            right: 0;
            transition: all 1s;
        }
        @media (max-width:951px) {
            font-size: .8em;
        }
    }
    .text {
        background: #f4f4f4;
        display: none;
        font-size: 1.2em;
        font-weight: 100;
        padding-left: 30px;
        padding-right: 30px;
    }
    input[type="checkbox"] {
        display: none;
        &:checked {
            & + .toggle-link::before {
                -webkit-transform: rotate(30deg);
                -moz-transform: rotate(30deg);
                -ms-transform: rotate(30deg);
                -o-transform: rotate(30deg);
                transform: rotate(90deg);
                background-position-x: 10px;
                transition: transform .4s;
            }
            & + .toggle-link {
                & + .text {
                    display: block;
                    padding-top: 10px;
                    padding-bottom: 10px;
                    margin-bottom: 2px;
                    margin-top:-2px;
                    animation: open-text .3s ease-in;
                }
                &::after {
                    content: "-";
                    transition: all 1s;
                }
            }
        }
    }
}
<div class="list-toggle">
   <input type="checkbox" id="anyid">
   <label for="anyid" class="toggle-link">Title Toggle</label>
  <div class="text"><p>Your Text</p></div>
</div>