Radio Button Based Tabs

Ugly styling, but it works

by Nick Iaconis

HTML

<div class="radio-tab-area">
    <input type="radio" name="group-1" class="radio-tab radio-tab-1" checked />
    <input type="radio" name="group-1" class="radio-tab radio-tab-2" />
    <input type="radio" name="group-1" class="radio-tab radio-tab-3" />
    <div class="radio-item radio-item-1">
        this is a test
    </div>
    <div class="radio-item radio-item-2">
        you could place any valid html in this area
    </div>
    <div class="radio-item radio-item-3">
        it truely is marvelous what you can do with a spash of css
    </div>
</div>

CSS

.radio-tab-area {
    position: relative;
    width: 480px;
}

.radio-tab {
    -webkit-appearance: none;
    width: 25%;
    height: 1.5rem;
    border-radius: 12px 12px 0 0;
    box-shadow: inset 0 0 12px hsla(0,0%,0%,.3);
    cursor: pointer;
    margin: 0;
}

.radio-tab-1 {
    content: 'tab 1';
}

.radio-tab:checked {
    box-shadow: inset 0 0 20px hsla(270,100%,50%,.3);
}

.radio-item {
    position: absolute;
    top: 1.5rem;
    width: 100%;
    opacity: 0;
    line-height: 1.8em;
    box-shadow: inset 0 0 20px hsla(0,0%,0%,.3);
    -webkit-transition: opacity 500ms;
    padding: 1rem;
}

.radio-tab-1:checked~.radio-item-1 {
    opacity: 1;
}

.radio-tab-2:checked~.radio-item-2 {
    opacity: 1;
}

.radio-tab-3:checked~.radio-item-3 {
    opacity: 1;
}