Web design and hosting, database, cloud and social media solutions that deliver business results
  • Soluciones de negocios
    • Automatización Robótica de Procesos
    • Software
    • Servicios de bases
      • Actualización del servidor y servicios de DBA
      • BI de energía
      • Integración de datos
      • Informes
    • Diseño web
      • Diseño de logo
      • Optimización del sitio web
      • Seguridad del sitio web
      • Traducción y localización web
      • Via de pago
      • Herramientas técnicas
    • Servicios en la nube
      • Servicios en la nube de Google
      • Servicios web de Amazon
      • microsoft azure
    • Medio Social
    • Microsoft Office
    • Hardware de TI
  • Academia
    • Nuestro entorno de prueba
    • Diseño de base de datos de aprendizaje
      • Los basicos
      • Obtener consulta abierta
      • Usando datos del servidor SQL
      • SQL Server 2008 para planes de mantenimiento
      • Usar fechas de SQL Server
      • Uso de las funciones de SQL Server
      • Uso de SQL Server Pivot-Unpivot
    • Aprendiendo Diseño Web
      • Creación del sistema de gestión de contenido de Ousia
      • ASP-NET
      • CSS
      • Usando JavaScript
    • Uso de las redes sociales
      • Cambiar una cuenta de Facebook de personal a empresa
      • Elegir dónde enfocar el esfuerzo de las redes sociales
      • Solicitar una revisión de Google
      • Tamaños de imagen de redes sociales
      • Uso de metadatos para configurar imágenes de redes sociales
    • Aprendizaje en la nube y servicios de TI
      • Error del programador de tareas 2147943645
      • Solicitud de SSL y generación de archivo PFX en OpenSSL Simple Steps
  • Acerca de
    • Blog
      • Actualización principal de Google, enero de 2020
      • Cierre de Internet de Hot Chilli
      • Cómo elegir el contenido de los folletos publicitarios de su sitio web
      • Construyendo una máquina de juego de nivel de entrada
      • Las cosas más molestas de los sitios web en Internet
      • Los 5 mejores sitios web para obtener gráficos vectoriales gratuitos
      • Prevención de estafas en línea
      • Skimmers de la gig economy
    • Carreras
      • Traductor inglés-español
      • Traductor inglés-japonés
    • Equipo
      • Ali Al Amine
      • Ayse Hur
      • Chester Copperpot
      • Gavin Clayton
      • Sai Gangu
      • suneel kumar
      • Surya Mukkamala
    • Portafolio
English (EN-GB)Español (ES)हिंदी (HI)日本語 (JA)Português (PT)

Caja ligera

Este Lightbox liviano pesa solo 6500 bytes, pero le permite mostrar imágenes en una variedad de formas con una interfaz increíblemente simple.

Our light box control is a light weight JavaScript plugin that works with any site, and comes as standard as part of our Ousia Content Management System.

It will work well in any of four ways;

  • Plain image
  • Image with caption text
  • Image wrapped in a hyperlink
  • Image wrapped in a hyperlink with caption

We've set some examples below, and provided all of the code you need to get it up and running.

If you use this in any code then please give us a mention somewhere in your site.

Plain Image

Image 1, no caption

Image and Caption

Image 2, with caption
Image 2, with caption

Hyperlink - No Caption

Image 3, wrapped in a hyperlink, no caption

Hyperlink - With Caption

Image 4, wrapped in a hyperlink with caption
Image 4, wrapped in a hyperlink with caption

HTML

<!--Image 1, no caption-->
<div style="text-align: center;">
<img title="Image 1, no caption" src="https://www.claytabase.co.uk/System/Themes/Default/cb.png" alt="Image 1, no caption" onload="lightBoxPush(this.src,this.alt)" onclick="lightBox(this)"/>
</div>
<!--Image 2, with caption-->
<div style="text-align: center;">
<figure style="display: inline !important;">
<img title="Image 2, with caption" src="https://www.claytabase.co.uk/System/Ousia/Ousia.png" alt="Image 2, with caption" onload="lightBoxPush(this.src,this.alt)" onclick="lightBox(this)"/>
<figcaption style="text-align: center;">Image 2, with caption</figcaption>
</figure>
</div>
<!--Image 3, wrapped in a hyperlink, no caption-->
<div style="text-align: center;">
<a class="galleryItemDiv" onclick="lightBox(this);return false" href="https://www.claytabase.co.uk/System/Artwork/Logos/MicrosoftPartnerBlack.png" target="_blank">
<img title="Image 3, wrapped in a hyperlink, no caption" src="https://www.claytabase.co.uk/System/Artwork/Logos/MicrosoftPartnerBlack.png" alt="Image 3, wrapped in a hyperlink, no caption" onload="lightBoxPush(this.src,this.alt)"/>
</a>
</div>
<!--Image 4, wrapped in a hyperlink with caption-->
<div style="text-align: center;">
<a class="galleryItemDiv" onclick="lightBox(this);return false" href="https://www.claytabase.co.uk/Business-Solutions/Web-Site-Design-Services/ResponsiveSite.png" target="_blank">
<figure style="display: inline !important;">
<img title="Image 4, wrapped in a hyperlink with caption" src="https://www.claytabase.co.uk/Business-Solutions/Web-Site-Design-Services/ResponsiveSite.png" alt="Image 4, wrapped in a hyperlink with caption" onload="lightBoxPush(this.src,this.alt)"/>
<figcaption style="text-align: center;">Image 4, wrapped in a hyperlink with caption</figcaption>
</figure>
</a>
</div>

JavaScript

var lightBoxImgs = [];
var lightBoxDiv;
var lightBoxDivInner;
var lightBoxImg;
var lightBoxCur;
var lightBoxTot;
var lightBoxDivDesc;
var lightBoxThumb;
 
function lightBoxCreate() {
    lightBoxDiv = document.createElement("div");
    lightBoxDiv.className = "oCdv lightBoxDiv"
    lightBoxDivInner = document.createElement("div");
    lightBoxDivInner.className = "lightBoxDivInner"
    var lightBoxDivLight = document.createElement("div");
    lightBoxDivLight.className = "lightBoxDivLight"
 
    var lightBoxDivLightCont = document.createElement("div");
    lightBoxDivLightCont.className = "lightBoxDivLightCont"
    lightBoxImg = document.createElement("img");
    lightBoxDivLightCont.appendChild(lightBoxImg)
    var lightBoxDivC = document.createElement("a");
    lightBoxDivC.className = "lightBoxDivC"
    lightBoxDivC.innerHTML = "X"
    lightBoxDivC.onclick = function () { lightBoxClose(); };
    lightBoxDivLightCont.appendChild(lightBoxDivC)
    var lightBoxDivR = document.createElement("a");
    lightBoxDivR.className = "lightBoxDivR"
    lightBoxDivR.innerHTML = ">"
    lightBoxDivR.onclick = function () { lightBoxR(this); };
    lightBoxDivLightCont.appendChild(lightBoxDivR)
    var lightBoxDivL = document.createElement("a");
    lightBoxDivL.className = "lightBoxDivL"
    lightBoxDivL.innerHTML = "<"
    lightBoxDivL.onclick = function () { lightBoxL(this); };
    lightBoxDivLightCont.appendChild(lightBoxDivL)
    var lightBoxDivT = document.createElement("span");
    lightBoxDivT.className = "lightBoxDivT"
    lightBoxCur = document.createElement("span");
    var lightBoxDivT2 = document.createElement("span");
    lightBoxDivT2.innerHTML = "/"
    lightBoxTot = document.createElement("span");
    lightBoxDivT.appendChild(lightBoxCur)
    lightBoxDivT.appendChild(lightBoxDivT2)
    lightBoxDivT.appendChild(lightBoxTot)
    lightBoxDivLightCont.appendChild(lightBoxDivT)
    lightBoxDivDesc = document.createElement("span");
    lightBoxDivDesc.className = "lightBoxDivDesc"
    lightBoxDivLightCont.appendChild(lightBoxDivDesc)
 
    lightBoxThumb = document.createElement("div");
    lightBoxThumb.className = "lightBoxDivThumb"
    lightBoxDivThumbInner = document.createElement("div");
    lightBoxDivThumbInner.className = "lightBoxDivThumbInner"
    lightBoxThumb.appendChild(lightBoxDivThumbInner)
 
    lightBoxDivLight.appendChild(lightBoxDivLightCont)
    lightBoxDivInner.appendChild(lightBoxDivLight)
    lightBoxDivInner.appendChild(lightBoxThumb)
    lightBoxDiv.appendChild(lightBoxDivInner)
    document.body.appendChild(lightBoxDiv)
}
 
function lightBoxPush(imgUrl, imgDesc) {
    if (typeof lightBoxDiv == 'undefined') {
        lightBoxCreate();
    }
    if (lightBoxGet(imgUrl) == -1) {
        lightBoxImgs.push([imgUrl, imgDesc]);
        var x = document.createElement("img");
        x.src = imgUrl;
        x.onclick = function () { lightBoxSet(imgUrl, '0'); };
        lightBoxThumb.children[0].appendChild(x);
    }
}
function lightBoxClose() {
    lightBoxDiv.className = "oCdv lightBoxDiv";
}
function lightBox(galleryItemDiv) {
    lightBoxDiv.className = "oCdv lightBoxDivAct";
    var src;
    if (galleryItemDiv.nodeName == "IMG") {
        src = galleryItemDiv.src;
    } else if (galleryItemDiv.children[0].nodeName == "IMG") {
        src = galleryItemDiv.children[0].src;
    } else if (galleryItemDiv.children[0].children[0].nodeName == "IMG") {
        src = galleryItemDiv.children[0].children[0].src;
    }
    lightBoxSet(src, 0);
    return false;
}
 
function lightBoxGet(imgSrc) {
    var result = -1;
    for (var i = 0, len = lightBoxImgs.length; i < len; i++) {
        if (lightBoxImgs[i][0] == imgSrc) {
            result = i;
            return result;
            break;
        };
    }
    return result;
}
function lightBoxSet(src, n) {
    var i = parseInt(lightBoxGet(src)) + parseInt(n);
    if (parseInt([i]) + 1 > parseInt(lightBoxImgs.length)) { i = 0 };
    if ([i] < 0) { i = parseInt(lightBoxImgs.length) - 1 };
    lightBoxImg.src = lightBoxImgs[i][0];
    lightBoxDivDesc.innerHTML = lightBoxImgs[i][1];
    lightBoxCur.innerHTML = parseInt([i]) + 1;
    lightBoxTot.innerHTML = parseInt(lightBoxImgs.length);
}
function lightBoxR(lightBox) {
    var src = lightBoxImg.src;
    lightBoxSet(src, 1);
}
function lightBoxL(lightBox) {
    var src = lightBoxImg.src;
    lightBoxSet(src, -1);
}

CSS

.lightBoxDiv{left:0px;top:0px;width:100%;display:block;opacity:0;}
.lightBoxDivAct{position:fixed;left:0px;top:0px;height:100%;width:100% !important;max-width:100% !important;background-color:#000;z-index:99999999;transition:1s ease;opacity:1;}
.lightBoxDiv .lightBoxDivInner{display:none;}
.lightBoxDivAct .lightBoxDivInner{display:block;}
.lightBoxDivInner{position:relative;max-width:1200px;margin:auto;height:100%;}
.lightBoxDivLight{position:relative;width:100%;height:75%;display:block;}
.lightBoxDivThumb{position:relative;width:100%;height:25%;display:block;white-space:nowrap;overflow:auto;overflow-y:hidden;}
.lightBoxDivThumbInner{height:100%;position:relative;}
.lightBoxDivThumbInner img{height:98%;padding:1% 2%;}
.lightBoxDivC{position:absolute;top:0px;right:0px;width:32px;height:32px;line-height:32px;color:#eee;vertical-align: middle;font-size:22px;font-family:Arial;font-weight:bold;padding:6px 6px;border-radius:10px;cursor: pointer;-webkit-user-select: none;}
.lightBoxDivL{position:absolute;top:50%;left:0px;width:32px;height:64px;line-height:64px;color:#eee;vertical-align: middle;font-size:32px;font-family:Arial;font-weight:bold;padding:0px 6px;margin-top:-38px;cursor: pointer;-webkit-user-select: none;}
.lightBoxDivR{position:absolute;top:50%;right:0px;width:32px;height:64px;line-height:64px;color:#eee;vertical-align: middle;font-size:32px;font-family:Arial;font-weight:bold;padding:0px 6px;margin-top:-38px;cursor: pointer;-webkit-user-select: none;}
.lightBoxDivT{position:absolute;top:0px;left:0px;height:64px;line-height:32px;color:#eee;vertical-align: middle;font-size:22px;font-family:Arial;padding:6px 6px;}
.lightBoxDivDesc{position:absolute;bottom:0px;left:0px;width:100%;line-height:32px;color:#eee;vertical-align: middle;font-size:22px;font-family:Arial;padding:6px 6px;background-color:#111;background-color:rgba(0,0,0,0.3);}
.lightBoxDivL:hover,.lightBoxDivR:hover,.lightBoxDivC:hover{background-color:#555;background-color:rgba(4,4,4,0.8)}   
.lightBoxDivLightCont{position:absolute;top:1%;left:1%;height:98%;width:98%;text-align:center;}
.lightBoxDivLightCont:before {content: ' ';display: inline-block;vertical-align: middle;height: 100%;}
.lightBoxDivLightCont img{max-width:96%;max-height:96%;margin:auto;display:inline-block;vertical-align:middle;}
Copyright Claytabase Ltd 2020

Registered in England and Wales 08985867

Site Links

RSSLoginLink Política de cookiesmapa del sitio

Social Media

facebook.com/Claytabaseinstagram.com/claytabase/twitter.com/Claytabaselinkedin.com/company/claytabase-ltd

Get in Touch

+442392064871info@claytabase.comClaytabase Ltd, Unit 3d, Rink Road Industrial Estate, PO33 2LT, United Kingdom

Partnered With

La configuración de este sitio está configurada para permitir todas las cookies. Éstos se pueden cambiar en nuestra página de configuración y política de cookies. Al continuar utilizando este sitio, usted acepta el uso de cookies.
Ousia Logo
Logout
Ousia CMS Loader