* { margin: 0; padding: 0; box-sizing: border-box; transition: 0.5s; } input { display:…
- User
- { margin: 0; padding: 0; box-sizing: border-box; transition: 0.5s; }
input { display: none; }
.display { width: 100%; height: 100vh; display: flex; align-items: center; justify-content: center; background: white; }
label { width: 400px; height: 200px; border-radius: 999px; background: #F3F3F3; box-shadow: 10px 10px 30px rgba(0, 0, 0, 0.05) inset; cursor: pointer; position: relative; }
.circle { width: 160px; height: 160px; border-radius: 99px; background: white; box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.05), -10px -10px 30px rgba(0, 0, 0, 0.05) inset; position: absolute; top: 50%; left: 0%; transform: translate(10%, -50%); display: flex; align-items: center; justify-content: center; overflow: hidden; } svg { width: 80px; position: absolute; } .sun { color: #FFD600; margin-top: 0%; opacity: 1; } .moon { margin-top: -150%; color: white; opacity: 0; }
input[type=checkbox]:checked + .display { background: #2C2C2F; } input[type=checkbox]:checked + .display label { background: #1F1F21; box-shadow: 10px 10px 30px rgba(0, 0, 0, 0.5) inset; } input[type=checkbox]:checked + .display label .circle { left: 100%; transform: translate(-110%, -50%); background: #2C2C2F; box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.5), -10px -10px 30px rgba(0, 0, 0, 0.5) inset; } input[type=checkbox]:checked + .display label .circle .sun { margin-top: 150%; opacity: 0; } input[type=checkbox]:checked + .display label .circle .moon { margin-top: 0%; opacity: 1; } label:active .circle { width: 200px;
- Assistant
Este código CSS y HTML implementa un interruptor de tema (claro/oscuro) con una interacción visual que cambia entre iconos de sol y luna dentro de un círculo al activar o desactivar un checkbox oculto.
- User
- { margin: 0; padding: 0; box-sizing: border-box; }
input[type="checkbox"] { display: none; }
.switch { width: 200px; /* Switch más grande / height: 100px; / Switch más grande */ background: #f3f3f3; border-radius: 50px; position: relative; cursor: pointer; transition: background 0.5s; }
.circle { width: 95px; /* Círculo más grande / height: 95px; / Círculo más grande / background: white; border-radius: 50%; box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.05), -10px -10px 30px rgba(0, 0, 0, 0.05) inset; position: absolute; top: 50%; / Asegura el centrado vertical dentro del switch */ left: 0%; transition: transform 0.5s; display: flex; align-items: center; justify-content: center; }
.circle i { font-size: 50px; /* Tamaño del icono aumentado */ transition: opacity 0.3s; }
.sun { color: #FFD700; /* Color del sol */ opacity: 1; }
.moon { color: #000000; /* Cambiar color de la luna a negro */ opacity: 0; }
input:checked + .switch { background: rgb(0, 0, 0); /* Cambiar el color de fondo del switch al activarse */ }
input:checked + .switch .circle { transform: translateX(100px); /* Aumentar desplazamiento para un switch más grande */ }
- Assistant
El problema parece estar relacionado con el uso del posicionamiento y transformación del círculo dentro del switch. Para asegurarte de que el círculo esté correctamente posicionado dentro del switch, verifica lo siguiente en el CSS:
- User
ahora se va en diagonal haia laderecha y los iconos no estanccentrados
- Assistant