#javascript #html #jquery #css #css3
Есть переключатель да-нет, который хочу стилизовать согласно дизайну
но пока не получается, вот наработки в фидле
$('input').styler();
div {
background-color: #964939;
color: white;
}
.jq-radio {
width: 28px;
height: 12px;
font-size: 16px;
font-weight: 700;
border: 0;
border-bottom: 3px dotted white;
border-radius: 0;
box-shadow: none;
background: transparent;
}
.jq-radio~span {
position: absolute;
top: -8px;
left: 6px;
}
.jq-radio.checked {
width: 64px;
height: 44px;
border: 2px solid white;
border-radius: 50%;
}
.jq-radio.checked~span {
position: absolute;
top: -4px;
left: 22px;
}
input[type="submit"] {
width: 204px;
height: 44px;
background-color: #ffd900;
color: #231f20;
font-size: 16px;
font-weight: 700;
padding: 0;
}
.jq-radio .jq-radio__div {
display: none;
}
Да
Нет
Ответы
Ответ 1
Вот на css: /* Базовые стили */ *, *:before, *:after { box-sizing: border-box; } body { background: #964939; } /* Cкрываем input[type="radio"] */ .radio { display: none; } /* Стили для кнопок */ .btn { display: inline-block; vertical-align: middle; width: 80px; height: 34px; text-align: center; padding: .5rem 1rem; color: #fff; font-family: sans-serif; cursor: pointer; position: relative; } /* dotted подчеркивание */ .btn:after { content: '....'; position: absolute; bottom: -3px; left: 0; right: 0; transition: all .34s ease-in-out; } /* Обертка для кнопок */ .list { position: relative; display: inline-block; } /* Перемещающийся блок */ .list:after { content: ''; position: absolute; top: 0; left: 0; right: 0; width: 80px; height: 38px; border: 2px solid #fff; border-radius: 25px; transition: all .34s ease-in-out; } /* "Да" */ #on:checked~.list:after { transform: translateX(0%); } #on:checked~.list .btn_on:after { opacity: 0; } /* "Нет" */ #off:checked~.list:after { transform: translateX(100%); } #off:checked~.list .btn_off:after { opacity: 0; }
Ответ 2
Както так? div{ background-color: #964939; color: white; padding: 5px; } .radio{ display: none; } .radio + label{ padding: 10px; margin-right: 2px; margin-left: 2px; border: none; } .radio + label > span{ border-bottom: 5px dotted; padding-left: 3px; /*add more dots*/ padding-right: 3px; padding-bottom: 2px; } .radio:checked + label{ /*add round border*/ border: 2px solid white; border-radius: 20px; margin-right: 0px; margin-left: 0px; } .radio:checked + label > span{ border-bottom: none ; /*remove dots*/ }
Комментариев нет:
Отправить комментарий