macOS estilo Mojave CheckBox & botón de radio en CSS puro

Tiempo de ejecución: 30 minutos. Empezar

Autor: Andreas Storm
Views Total: 1,086
Sitio oficial: Ir a la web
Actualizado: June 27, 2018
Licencia: MIT

Vista prévia

macOS estilo Mojave CheckBox & botón de radio en CSS puro

Descripción

Hace uso de SVG y HTML/CSS para crear una casilla animada & entradas de botones de radio inspiradas en el modo oscuro de macOS Mojave.

See also:

Funcionamiento

Cree el código HTML para la casilla de verificación & entradas de botón de radio.

<div class="forms">

<label for="cbk">


<input type="checkbox" id="cbk">


<span class="cbx">



<svg width="12px" height="11px" viewBox="0 0 12 11">




<polyline points="1 6.29411765 4.5 10 11 1"></polyline>



</svg>


</span>


<span>Checkbox</span>

</label>


<label for="rdo">


<input type="radio" id="rdo" name="radio">


<span class="rdo"></span>


<span>Radio Button</span>

</label>
</div>

Los estilos CSS/CSS3.

.cbx {

position: relative;

display: block;

float: left;

width: 18px;

height: 18px;

border-radius: 4px;

background-color: #606062;

background-image: linear-gradient(#474749, #606062);

box-shadow: inset 0 1px 1px rgba(255,255,255,0.15), inset 0 -1px 1px rgba(0,0,0,0.15);

transition: all 0.15s ease;
}

.cbx svg {

position: absolute;

top: 3px;

left: 3px;

fill: none;

stroke-linecap: round;

stroke-linejoin: round;

stroke: #fff;

stroke-width: 2;

stroke-dasharray: 17;

stroke-dashoffset: 17;

transform: translate3d(0, 0, 0);
}

.rdo {

position: relative;

display: block;

float: left;

width: 18px;

height: 18px;

border-radius: 10px;

background-color: #606062;

background-image: linear-gradient(#474749, #606062);

box-shadow: inset 0 1px 1px rgba(255,255,255,0.15), inset 0 -1px 1px rgba(0,0,0,0.15);

transition: all 0.15s ease;
}

.rdo:after {

content: "";

position: absolute;

display: block;

top: 6px;

left: 6px;

width: 6px;

height: 6px;

border-radius: 50%;

background: #fff;

opacity: 0;

transform: scale(0);
}

.cbx + span,
.rdo + span {

float: left;

margin-left: 6px;
}

.forms {

margin: auto;

user-select: none;
}

.forms label {

display: inline-block;

margin: 10px;

cursor: pointer;
}

.forms input[type="checkbox"],
.forms input[type="radio"] {

position: absolute;

opacity: 0;
}

.forms input[type="radio"]:checked + .rdo {

background-color: #606062;

background-image: linear-gradient(#255cd2, #1d52c1);
}

.forms input[type="radio"]:checked + .rdo:after {

opacity: 1;

transform: scale(1);

transition: all 0.15s ease;
}

.forms input[type="checkbox"]:checked + .cbx {

background-color: #606062;

background-image: linear-gradient(#255cd2, #1d52c1);
}

.forms input[type="checkbox"]:checked + .cbx svg {

stroke-dashoffset: 0;

transition: all 0.15s ease;
}

Te puede interesar: