Gallery

Mostrando entradas con la etiqueta javascript. Mostrar todas las entradas
Mostrando entradas con la etiqueta javascript. Mostrar todas las entradas

jueves, 6 de agosto de 2026

JS - Creando el espacio en tu sitio web

 Espacio estelar en tu sitio web con Javascript


Código para no perder la línea--

Espero poder poner contenido dentro del espacio, que hasta ahorita no he podido.

-------------------------HTML5
<canvas id="canvas"></canvas>

-------------------------CSS3
#canvas{
    width: 100%;
    height: 150px;
    background: black;
}

-------------------------CSS3
// Canva espacial black and estrellas
  const canvas = document.getElementById('canvas');
  const ctx = canvas.getContext('2d');

  canvas.width = window.innerWidth;
  canvas.height = window.innerHeight;

  // Crear lista de estrellas
  const numEstrellas = 200;
  const estrellas = [];

  for (let i = 0; i < numEstrellas; i++) {
    estrellas.push({
      x: Math.random() * canvas.width,
      y: Math.random() * canvas.height,
      tam: Math.random() * 5,
      vel: Math.random() * 1.5 + 3.5 // Velocidad de movimiento
    });
  }

  function animar() {
    // Limpiar pantalla
    ctx.clearRect(0, 0, canvas.width, canvas.height);
    ctx.fillStyle = 'white';

    // Actualizar y dibujar cada estrella
    estrellas.forEach(e => {
      e.x += e.vel; // Mover a la derecha

      // Si pasa el borde derecho, regresar a la izquierda (infinito)
      if (e.x > canvas.width) {
        e.x = 10;
        e.y = Math.random() * canvas.height; // Nueva posición vertical opcional
      }

      // Dibujar estrella
      ctx.fillRect(e.x, e.y, e.tam, e.tam);
    });

    requestAnimationFrame(animar);
  }

  animar(); Si logras poner contenido dentro del espacio, hay que compartir el como...

jueves, 30 de julio de 2026

JS - Protegiendo la página web

Proteger tu sitio web con un código simple pero poderoso con Javascript.

He acá hemos dejado el código para que puedan utilizarlo, copiar y pegar como siempre.

<script>validarPassword();</script>

function validarPassword(){
    texto = prompt("Para ver la página introduzca su contraseña");
    while(texto!="titojefe.123"){
        alert("Password incorrecta");
        texto = prompt("Para ver la página introduzca su contraseña");
    }
    alert("Password Correcta");
}

Y hay que dejar la fuente de donde lo encontramos. Origen Siempre hay que agradecer a quienes construyen herramientas para los demás.

sábado, 2 de agosto de 2025

Menú lateral con funcion para ver contenido

Menú lateral con funcion para ver contenido




HTML5
<!-- SECTION BOTONES TREN -->

Galeria Lightbox

 Galeria Lightbox




Código HTML5 CSS & JAVASCRIPT

Esta demasiado bueno para ser cierto.

Para que funcione el código tiene que tener:
*{
    box-sizing: border-box;
}

HTML5

<!-- LIGHTBOX IMAGENES Y VIDEOS -->
    <div class="container">

        <div class="gallery">
            <!-- Image Items -->

domingo, 20 de julio de 2025

Slider con botones laterales y de localizacion

SLIDER CON BOTONES LATERALES Y DE LOCALIZACION.

CODIGO HTML5

<div class="slider-container">
            <div class="slider-track">
                <div class="slider-slide">
                    <img src="https://cdn-prod.puprod.indreams.me/"
                        alt="Resident Evil" class="slider-image">
                    <div class="slider-content">
                        <h2 class="slider-title">Shelly</h2>
                        <p class="slider-description">Conocida como
                            japonesa creada por Capcom.</p>
                    </div>
                </div>
                   
                <div class="slider-slide">
                    <img src="https://wotpack.ru/wp-content/uploads.jpg"
                            alt="Silent Hill" class="slider-image">
                    <div class="slider-content">
                        <h2 class="slider-title">Silent Hill</h2>
                        <p class="slider-description">Es una franquicia de videojuegos
                            publicada por Konami y su subsidiaria,
                                        Konami Digital Entertainment. </p>
                    </div>
                </div>

                <div class="slider-slide">
                    <img src="https://i.ytimg.com/vi/JwbhEACR8Vg/maxresdefault.jpg" alt="Dandys World" class="slider-image">
                    <div class="slider-content">
                        <h2 class="slider-title">Dandys World</h2>
                        <p class="slider-description">Es un juego multijugador de terror con mascotas creado por BlushCrunch Studio</p>
                    </div>
                </div>

                <div class="slider-slide">
                    <img src="https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/46cf2012-9552-434b-8a38-4b3bbc923fbe/diqzaqm-a8a1d40d-d3f0-48a6-8eb6-a0d378fcf6d0.jpg/v1/fill/w_1280,h_960,q_75,strp/dino_shelly_by_sweetzcherrys_diqzaqm-fullview.jpg?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7ImhlaWdodCI6Ijw9OTYwIiwicGF0aCI6IlwvZlwvNDZjZjIwMTItOTU1Mi00MzRiLThhMzgtNGIzYmJjOTIzZmJlXC9kaXF6YXFtLWE4YTFkNDBkLWQzZjAtNDhhNi04ZWI2LWEwZDM3OGZjZjZkMC5qcGciLCJ3aWR0aCI6Ijw9MTI4MCJ9XV0sImF1ZCI6WyJ1cm46c2VydmljZTppbWFnZS5vcGVyYXRpb25zIl19.LDmrTRgdGZZEKARarcCDHoeakH61QQ2pF5ixbq4B93k" alt="Brawl Stars" class="slider-image">
                    <div class="slider-content">
                        <h2 class="slider-title">Brawl Stars</h2>
                        <p class="slider-description">Es un videojuego multijugador para móviles disponible en Android y iOS, desarrollado por Supercell y lanzado globalmente en 2018.</p>
                    </div>
                </div>

                <div class="slider-slide">
                    <img src="https://media.sketchfab.com/models/53c1f63911ef4c53b0053ce13c23b4fe/thumbnails/53d0ce722e49492d9d09514e9d7f4bfd/31e87f035af1447ab11d7a5f7ad97c95.jpeg" alt="God of War Ragnarok" class="slider-image">
                    <div class="slider-content">
                        <h2 class="slider-title">God of War Ragnarok</h2>
                        <p class="slider-description">Es un videojuego de acción y aventura hack and slash en tercera persona desarrollado por Santa Monica Studio y publicado por Sony Interactive Entertainment.</p>
                    </div>
                </div>
            </div>

            <div class="slider-nav">
                <button class="slider-btn prev"></button>
                <button class="slider-btn next"></button>
            </div>

            <div class="slider-dots">
                <div class="slider-dot"></div>
                <div class="slider-dot"></div>
                <div class="slider-dot"></div>
                <div class="slider-dot"></div>
                <!-- Al querer agregar o quitar una imagen nueva,
                tendremos que modificar estos botones,
                tienen que ir iguales 5==5 -->
                <div class="slider-dot active"></div>
            </div>
        </div>
   

CÓDIGO CSS


.slider-container {
    width: 100%; /*** ancho de donde esta la imagen, ajuste en px ***/
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}
.slider-track {
    display: flex;
    transition: transform 0.5s ease-in-out;
    height: 100vh; /*** alto de donde esta la imagen,
                    ajuste a la par de contaniner ***/
}
.slider-slide {
    min-width: 100%; /*** no mover este min-width ***/
    position: relative;
}
.slider-image {
    width: 100%; /*** va a la par de .slider-track ***/
    height: 100%; /*** va a la par de .slider-track ***/
    object-fit: cover;
}
.slider-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    color: white;
    padding: 30px;
    padding-top: 80px;
}
.slider-title {
    font-size: 2.2rem;
    margin-bottom: 10px;
    font-weight: 700;
}
.slider-description {
    font-size: 1rem;
    line-height: 1.6;
    max-width: 70%; /*** ajustar cada que se mueva el ancho en porcentajes,
                es para el texto ***/
}
.slider-nav {
    position: absolute;
    top: 50%;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
}
.slider-btn {
    background-color: rgba(255, 255, 255, 0.7);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}
.slider-btn:hover {
    background-color: rgba(122, 19, 19, 0.9);
    transform: scale(1.1);
    color: white;
}
.slider-dots {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10;
}
.slider-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.3s ease;
}
.slider-dot.active {
    background-color: rgb(187, 255, 0);
    transform: scale(1.2);
}

CODIGO JS

document.addEventListener('DOMContentLoaded', function() {
            const track = document.querySelector('.slider-track');
            const slides = document.querySelectorAll('.slider-slide');
            const dots = document.querySelectorAll('.slider-dot');
            const prevBtn = document.querySelector('.prev');
            const nextBtn = document.querySelector('.next');
           
            let currentIndex = 0;
            let slideWidth = slides[0].clientWidth;
            let autoSlideInterval;
            const slideCount = slides.length;
           
            // Set up slider
            function initSlider() {
                slideWidth = slides[0].clientWidth;
                track.style.width = `${slideWidth * slideCount}`;
               
                // Set initial active dot
                updateDots();
               
                // Start auto slide
                startAutoSlide();
               
                // Handle window resize
                window.addEventListener('resize', function() {
                    slideWidth = slides[0].clientWidth;
                    track.style.width = `${slideWidth * slideCount}`;
                    goToSlide(currentIndex);
                });
            }
           
            // Go to specific slide
            function goToSlide(index) {
                if (index < 0) {
                    index = slideCount - 1;
                } else if (index >= slideCount) {
                    index = 0;
                }
               
                currentIndex = index;
                track.style.transform = `translateX(-${slideWidth * currentIndex}px)`;
                updateDots();
               
                // Reset auto slide timer
                resetAutoSlide();
            }
           
            // Update navigation dots
            function updateDots() {
                dots.forEach((dot, index) => {
                    dot.classList.toggle('active', index === currentIndex);
                });
            }
           
            // Auto sliding
            function startAutoSlide() {
                autoSlideInterval = setInterval(() => {
                    goToSlide(currentIndex + 1);
                }, 5000);
            }
           
            function resetAutoSlide() {
                clearInterval(autoSlideInterval);
                startAutoSlide();
            }
           
            // Event listeners
            prevBtn.addEventListener('click', () => {
                goToSlide(currentIndex - 1);
            });
           
            nextBtn.addEventListener('click', () => {
                goToSlide(currentIndex + 1);
            });
           
            // Dot navigation
            dots.forEach((dot, index) => {
                dot.addEventListener('click', () => {
                    goToSlide(index);
                });
            });
           
            // Pause on hover
            track.addEventListener('mouseenter', () => {
                clearInterval(autoSlideInterval);
            });
           
            track.addEventListener('mouseleave', () => {
                resetAutoSlide();
            });
           
            // Initialize slider
            initSlider();
        });

Termina código del slider

domingo, 3 de noviembre de 2024

GADGET - Fantasmas de Mario Bros en tu sitio web

FANTASMAS EN 


Todo esto va dentro de html5. Esperemos que funcione para después... 

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js' type='text/javascript'></script>

<style>
  .ghost {
      position: absolute;
      width: 100px;
      height: 100px;
      z-index: 10001;
      display: block;
      opacity: 0.8;
      background: transparent url('img/phantom.png') no-repeat;
  }

  .ghost.moving-left {
      -moz-transform: scaleX(-1);
      -webkit-transform: scaleX(-1);
      -o-transform: scaleX(-1);
      transform: scaleX(-1);
      filter: fliph;
      /*IE*/
  }
</style>

<script>
  var Ghost = function () {
      var a = {};
      if (jQuery.browser.msie) {
          if (jQuery.browser.version < 8) {
              return a;
          }
      }
      a.html = '<div class="ghost"></div>';
      a.element = null;
      a.timer = null;
      a.interval = Math.floor(Math.random() * 1e3) + 1e3;
      a.directionX = Math.round(Math.random());
      a.directionY = Math.round(Math.random());
      if (a.directionX == 0) {
          a.directionX = -1;
      }
      if (a.directionY == 0) {
          a.directionY = -1;
      }
      a.screenWidth = null;
      a.screenHeight = null;
      a.elementWidth = 150;
      a.elementHeight = 145;
      a.init = function () {
          a.getBrowserSize();
          jQuery(window).resize(function () {
              a.getBrowserSize();
          });
          a.element = jQuery(a.html);
          a.timer = window.setInterval(a.move, a.interval);
          jQuery("body").append(a.element);
          a.move(true);
          a.move();
          return a;
      };
      a.move = function (b) {
          var c = Math.floor(Math.random() * 100 + 100);
          var d = Math.floor(Math.random() * 100 + 100);
          var e = a.element.offset().left;
          var f = a.element.offset().top;
          var g = e + a.directionX * c;
          var h = f + a.directionY * d;
          var i = a.screenWidth - a.elementWidth - 20;
          var j = a.screenHeight - a.elementHeight;
          if (g > i) {
              g = i;
              a.directionX = -a.directionX;
          } else if (g < 0) {
              g = 0;
              a.directionX = -a.directionX;
          }
          if (h > j) {
              h = j;
              a.directionY = -a.directionY;
          } else if (h < 0) {
              h = 0;
              a.directionY = -a.directionY;
          }
          var k = Math.random() - 0.1;
          if (k < 0.4) {
              k = 0.4;
          }
          if (b) {
              a.element.css(
                  "top",
                  Math.floor(Math.random() * a.screenHeight - a.elementHeight)
              );
              a.element.css(
                  "left",
                  Math.floor(Math.random() * a.screenWidth - a.elementWidth)
              );
          } else {
              a.element.removeClass("moving-left");
              a.element.removeClass("moving-right");
              if (g > e) {
                  a.element.addClass("moving-right");
              } else if (g < e) {
                  a.element.addClass("moving-left");
              }
              a.element.stop();
              a.element.animate(
                  { top: h, left: g, opacity: k },
                  { duration: a.interval, easing: "swing" }
              );
          }
      };
      a.getBrowserSize = function () {
          a.screenWidth = jQuery(document).width();
          a.screenHeight = jQuery(document).height();
      };
      a.init();
      return a;
  };

  jQuery(function () {
      var Ghosts = new Array();
      for (var i = 0; i < 30; i++) {
          Ghosts.push(new Ghost());
      }
  });
</script>

Documental de Hackers