Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="fondo" id="fondo">

  <div class="luz" id="luz"></div>
  <div class="lampara" id="lampara"></div>
  <div class="lampara2" id="lampara2"></div>
  <div class="cable" id="cable"></div>
  <div class="caragrande"></div>
  
  <div class="contenedor">q
  
  <div class="cuadro1" id="cuadro1"></div>
  <div class="cuadro2" id="cuadro2"></div>
  <div class="cuadro3" id="cuadro3"></div>
  <div class="cuadro4" id="cuadro4"></div>
  <div class="cuerpo-gato1" id="cuerpo-gato1"></div>
  <div class="cabeza-gato1" id="cabeza-gato1"></div>
  <div class="oreja1"></div>
  <div class="oreja2"></div>
  <div class="rabo1"></div>
  <div class="rabo2"></div>
  <div class="bigote1"></div>
  <div class="bigote2"></div>
  <div class="bigote3"></div>
  <div class="bigote4"></div>
  <div class="bigote5"></div>
  <div class="bigote6"></div>
  <div class="sol" id="sol"></div>
   <div class="sol2" id="sol2"></div>
 
  <div class="luna1" id="luna1"></div>
  <div class="luna2" id="luna2"></div>
  
  <div class="estrellas-efectos" id="todas_estrellas">
    <ul>
   <li class="estrella" id ="estrella1"></li>
   <li class="estrella" id ="estrella2"></li>
   <li class="estrella" id ="estrella3"></li>
   <li class="estrella" id ="estrella4"></li>
   <li class="estrella" id ="estrella5"></li>
   <li class="estrella" id ="estrella6"></li>
   <li class="estrella" id="estrella7"></li>
   <li class="estrella" id="estrella8"></li>
   <li class="estrella" id="estrella9"></li>
   <li class="estrella" id="estrella10"></li>
   <li class="estrella" id="estrella11"></li>
   <li class="estrella" id="estrella12"></li>
   <li class="estrella" id="estrella13"></li>
   <li class="estrella" id="estrellafugaz"></li>
      
</ul>
  </div>
</div>
<div class ="buttons">
  <button class="noche" id="boton_noche"> Me gusta la noche --></button>
   <button class="luna" id="boton_luna">La luz de la luna -></button>
  <button class="estrellas" id="boton_estrellas"> ... y las estrellas -> </button>
   <button class="deseo" id="boton_deseo"> Pide un deseo --> </button>
  
</div>
 
   
</div>

              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Schoolbell&display=swap');

*{
  font-family: 'Schoolbell', cursive;
  font-size: 1.1em;
 --blue: #38A9A6;
 --sky-blue: #A9D4E7;
 --green: #9ECDA5;
 --soft-green: #DFE8BC;
 --dark: #483E35;
 --color: #D06D6C; 
  --yellow: #DD8344;
  --night: #111A32;
}

.fondo {
  background-color: var(--blue);
  padding: 3em;
  position: relative;
  width: 1500px;
  margin-left: auto; 
  margin-right: auto;
}

.contenedor
{
  position: relative;
  width: 400px;
  height: 400px;
  border: solid 3px var(--dark);
  margin-left: auto;
  margin-right: auto;
  background-color: var(--color);
  box-shadow: 5px 5px 5px  var(--dark);
  
}

.buttons {
  display: relative;
}

.luz{
  position:absolute;
  border-width: 280px;
  border-style: solid;
  border-color: transparent rgba(70, 200, 163, 0.363)  rgba(70, 200, 163, 0.363) transparent;
  left: 62.9%;
  top: 40%;
  transform: rotate(225deg);
  z-index:1;
}

.lampara{
   position:absolute;
  border-width: 80px;
  border-style: solid;
  border-color: transparent var(--dark) var(--dark)
  transparent;
  left: 75.5%;
  top: 11%;
  transform: rotate(225deg);
  border-radius: 30%;
  z-index:3;
  
}

.lampara2{
   position:absolute;
  border-width: 30px;
  border-style: solid;
  border-color: yellow;
 z-index:2;
  left: 78.6%;
  top: 19%;
  transform: rotate(225deg);
  border-radius: 50%;
}


.cable{
  position: absolute;
  width: 10px;
  height: 100px;  ;  
  top: 0%;
  right: 18.9%;
  background-color: var(--dark);
  border-width: 5px;
  border-color: gray;
  border-style: solid;
  border-radius: 50%;
}


.cuadro1
{
  position: absolute;
  border: 1px solid black;
  width: 185px;
  height: 185px;
  top:2%;
  left: 2%;
  z-index: 2;
  background-color: var(--sky-blue);
}

.cuadro2
{
  position: absolute;
  z-index: 2;
  border: 1px solid black;
  width: 185px;
  height: 185px;
  top:2%;
  left: 51%;
  background-color: white;
  background-color: var(--sky-blue);
}

.cuadro3
{
  position: absolute;
  z-index: 2;
  border: 1px solid black;
  width: 185px;
  height: 185px;
  top:51%;
  left: 51%;
  background-color: var(--sky-blue);
}

.cuadro4
{
  position: absolute;
  z-index: 2;
  border: 1px solid black;
  width: 185px;
  height: 185px;
  top:51%;
  left: 2%;
  background-color: var(--sky-blue);
}

.cuerpo-gato1
{
  position: absolute;
  z-index: 3;
  border: 1px solid black;
  width: 70px; 
  height: 90px;
  border-radius: 50% 50% 29% 29%;
  top: 74.5%;
  right: 10%; 
  background: black;
  
}

.sol {
  position: absolute;
  z-index: 3;
 
  width: 50px; 
  height: 50px;
  border-radius: 50%;
  top: 11.5%;
  right: 72%; 
  background: var(--yellow);
}

.sol2{
  position: absolute;
  z-index: 2;
  width: 60px; 
  height: 60px;
  border-radius: 50%;
  top: 10.6%;
  right: 70.9%; 
  background: yellow;
}

.cabeza-gato1
{
  position: absolute;
  z-index: 3;
  width: 45px;
  height: 38px;
  border: 1px solid black;
  border-radius: 48%;
  top: 66%;
  right: 13.6%;
  background: black;
}

.oreja1
{
  position: absolute;
  z-index: 3;
  top: 62.2%;
  right: 21%;
  border-color: transparent transparent black;
  border-width: 12.5px;
  border-style: solid;
  transform: rotate(-33deg);
 
}

.oreja2
{
  position: absolute;
  z-index: 3;
  top: 61.5%;
  right: 12.5%;
  border-color: transparent transparent black;
  border-width: 12.5px;
  border-style: solid;
  transform: rotate(25deg);
 
}

.rabo1
{
  position:absolute;
  z-index: 3;
  width: 120px; 
  height: 100px;  
  border: solid 11px #000;
  border-color: #000 transparent transparent transparent;
  border-radius: 50%/100px 100px 0 0;
  transform: rotate(120deg);
  top: 80%;
  right: 15%;
   animation-iteration-count: infinite;
   animation-duration: 3s;
  animation-name: slidein;

}



.rabo2
{
  position: absolute;
  z-index: 3;
  width: 13px;
  height: 17px;
  background-color: black;
  top: 106%;
  right:29%;
  border-radius: 50%;
  transform: rotate(60deg);
  
}

.bigote1
{
  position: absolute;
  z-index: 4;
  width: 50px; 
  height: 100px;  
  border: solid 2px #000;
  border-color: #000 transparent transparent transparent;
  border-radius: 50%/100px 100px 0 0;
  
  top: 72%;
  right: 21%;
  transform: rotate(30deg);
  
}

.bigote2
{
  position: absolute;
  z-index: 4;
  width: 50px; 
  height: 100px;  
  border: solid 2px #000;
  border-color: #000 transparent transparent transparent;
  border-radius: 50%/100px 100px 0 0;
  top: 70%;
  right: 22%;
  transform: rotate(30deg);
  
}

.bigote3{
  position: absolute;
  z-index: 4;
  width: 50px; 
  height: 100px;  
  border: solid 2px #000;
  border-color: #000 transparent transparent transparent;
  border-radius: 50%/100px 100px 0 0;
  top: 71%;
  right: 21%;
  transform: rotate(30deg);
}

.bigote4
{
  position: absolute;
  z-index: 4;
  width: 20px;
  border: solid 1px #000;
  top: 70%;
  right: 12%;
  transform: rotate(20deg);
}

.bigote5
{
  position: absolute;
  z-index: 4;
  width: 20px;
  border: solid 1px #000;
  top: 71%;
  right: 12%;
  transform: rotate(20deg);
}

.bigote6
{
  position: absolute;
  z-index: 4;
  width: 20px;
  border: solid 1px #000;
  top: 72%;
  right: 12%;
  transform: rotate(20deg);
}

button
{
 position: absolute;
 width:220px;
 height: 70px;
 box-shadow: 0 0 40px #fff;
}

.noche{
 position: absolute;
 z-index: 4;
 left:18%;
 top: 35%;
 background-color:#C2B769;
}

.luna
{
 z-index: 4;
 left: 18%;
 top: 35%;
 background-color: pink;
}

.luna1
{
  position: absolute;
  z-index: 6;
  width: 60px;
  height: 60px;
  top: 10%;
  left: 13%;
  border-radius: 50%;
  background-color: white;
  box-shadow: 0 0 8.5px #fff;
  
}

.luna2
{
  position: absolute;
  z-index: 7;
  width: 60px;
  height: 60px;
  top: 10%;
  left: 18%;
  border-radius: 50%;
  background-color:var(--night);
  
}

.estrellas {
 z-index: 7;
 left: 18%;
 top: 35%;
 background-color: yellow;
}

.deseo {
  z-index: 7;
  left:18%;
  top:35%;
  background-color: orange;
  
}

.estrella {
  position: absolute;
  z-index: 7;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: yellow;
}

#estrella1 {
  top: 30%;
  left:35%;
}

#estrella2 {
  top: 20%;
  left:65%;
}

#estrella3 {
  top: 10%;
  left:75%;
}

#estrella4 {
  top: 35%;
  left:75%;
}

#estrella5 {
  top: 60%;
  left:25%;
}

#estrella6{
  top: 70%;
  left: 60%;
}

#estrella7 {
  top: 59%;
  left: 89%;
}

#estrella8 {
  top: 6%;
  left: 92%;
}

#estrella9 {
  top: 21%;
  left: 4%;
}

#estrella10 {
  top: 9%;
  left: 32%;
}

#estrella11 {
  top: 13%;
  left: 62%;
}

#estrella12 {
  top: 32%;
  left: 12%;
}

#estrella13 {
  top: 38%;
  left: 39%;
}


#estrellafugaz {
  top: 45%;
  left: 5%;
  animation-name: spin;
  animation-duration: 4s;
  animation-iteration-count: 1;
  width: 5px;
  height: 5px;
  border-radius: 50%;
   
}


@keyframes spin {
 from {
  
    width: 1%; 
  }

  75% {
   top: 10%;
    margin-left: 25%;
    width: 1%;
  }

  to {
    margin-left: 0%;
    width: 0%;
    
  }
}


button {
  font-size: 0.8em;
   opacity: .8;
    transition: all 300ms linear;
}

button:hover {
    transition: all 150ms linear;
    background: white;
  }
              
            
!

JS

              
                let cuadro1 = document.getElementById("cuadro1");
let cuadro2 = document.getElementById("cuadro2");
let cuadro3 = document.getElementById("cuadro3");
let cuadro4 = document.getElementById("cuadro4");
let pared = document.getElementById("fondo");
let estrella1 = document.getElementById("estrella1");
let estrella2 = document.getElementById("estrella2");
let estrella3 = document.getElementById("estrella3");
let estrella4 = document.getElementById("estrella4");
let estrella5 = document.getElementById("estrella5");
let estrella6 = document.getElementById("estrella6");
let estrella7 = document.getElementById("estrella7");
let estrella8 = document.getElementById("estrella8");
let estrella9 = document.getElementById("estrella9");
let estrella10 = document.getElementById("estrella10");
let estrella11 = document.getElementById("estrella11");
let estrella12 = document.getElementById("estrella12");
let estrella13 = document.getElementById("estrella13");




let button_noche = document.getElementById("boton_noche");

let luna1 = document.getElementById("luna1");
let luna2 = document.getElementById("luna2");

let button_luna = document.getElementById("boton_luna");


let estrellafugaz = document.getElementById("estrellafugaz");

let button_fugaz = document.getElementById("boton_deseo");

let button_estrellas = document.getElementById("boton_estrellas");

let sol = document.getElementById("sol");
let sol2 = document.getElementById("sol2");

let cuerpo_de_gato = document.getElementById("cuerpo-gato1");

let cabeza_de_gato = document.getElementById("cabeza-gato1");

let luz = document.getElementById("luz");
let lampara2 = document.getElementById("lampara2");


window.onload = function(){
  button_luna.style.display = "none";
  luna1.style.display = "none";
  luna2.style.display = "none";
  button_estrellas.style.display = "none";
  button_fugaz.style.display = "none";
  luz.style.display = "none";
  lampara2.style.borderColor = "white";
  estrella1.style.display = "none";
  estrella2.style.display = "none";
  estrella3.style.display = "none";
  estrella4.style.display = "none";
  estrella5.style.display = "none";
  estrella6.style.display = "none";
  estrella7.style.display = "none";
  estrella8.style.display = "none";
  estrella9.style.display = "none";
  estrella10.style.display = "none";
  estrella11.style.display = "none";
  estrella12.style.display = "none";
  estrella13.style.display = "none";
  
  estrellafugaz.style.display = "none";
}


button_noche.onclick = function() {
  cuadro1.style.backgroundColor = "var(--night)";
  cuadro2.style.backgroundColor = "var(--night)";
  cuadro3.style.backgroundColor = "var(--night)";
  cuadro4.style.backgroundColor = "var(--night)";
  button_luna.style.display = "block";
  button_noche.style.display  = "none";
  sol.style.display = "none";
  sol2.style.display = "none";
  lampara2.style.borderColor = "yellow";
  luz.style.display = "block";
  pared.style.backgroundColor = "rgb(40, 116, 113)";
  estrellafugaz.style.display = "none";
                      
}

button_luna.onclick = function(){
  luna1.style.display = "block";
  luna2.style.display = "block";
  button_estrellas.style.display = "block";
  button_luna.style.display = "none";          cuerpo_de_gato.style.boxShadow = "0px 0px 30px #fff";
 
}


button_estrellas.onclick = function(){
  estrella1.style.display = "block";
  estrella2.style.display = "block";
  estrella3.style.display = "block";
  estrella4.style.display = "block";
  estrella5.style.display = "block";
  estrella6.style.display = "block";
  estrella7.style.display = "block";
  estrella8.style.display = "block";
  estrella9.style.display = "block";
  estrella10.style.display = "block";
  estrella11.style.display = "block";
  estrella12.style.display = "block";
  estrella13.style.display = "block";
 
  button_fugaz.style.display = "block";
  button_estrellas.style.display = "none";

}

button_fugaz.onclick = function() {
 
  button_estrellas.style.display = "none";
  estrellafugaz.style.display = "block";
  setTimeout(desactivarEstrella, 3000);
}


function getRandomInt(min, max) {
  min = Math.ceil(min);
  max = Math.floor(max);
  return Math.floor(Math.random() * (max - min + 1)) + min;
}

function getRandomColor() {
  const red = getRandomInt(0, 255);
  const green = getRandomInt(0, 255);
  const blue = getRandomInt(0, 255);

  return `rgb(${red}, ${green}, ${blue})`;
}

const stars = document.querySelectorAll("li");

function colorStar() {
  const chosen = stars[getRandomInt(0, stars.length - 1)];
  chosen.style.backgroundColor = getRandomColor();
}

setInterval(colorStar, 20);

function desactivarEstrella (){
    estrellafugaz.style.display = "none";
  }



              
            
!
999px

Console