"image popup"
Bootstrap 4.1.1 Snippet by ALIMUL AL RAZY

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="row"> <div id="imgbox"> <img id='img1' src='https://cdn.pixabay.com/photo/2017/11/12/13/37/forest-2942477_960_720.jpg 1x, https://cdn.pixabay.com/photo/2017/11/12/13/37/forest-2942477_1280.jpg 1.333x' onmouseover="Large(this)" /> </div> </div> </div>
#imgbox { vertical-align : middle; position : absolute; border: 1px solid #999; background : #FFFFFF; filter: Alpha(Opacity=100); visibility : hidden; height : 200px; width : 200px; z-index : 50; overflow : hidden; text-align : center; }
function getElementLeft(elm) { var x = 0; //set x to elm’s offsetLeft x = elm.offsetLeft; //set elm to its offsetParent elm = elm.offsetParent; //use while loop to check if elm is null // if not then add current elm’s offsetLeft to x //offsetTop to y and set elm to its offsetParent while(elm != null) { x = parseInt(x) + parseInt(elm.offsetLeft); elm = elm.offsetParent; } return x; } function getElementTop(elm) { var y = 0; //set x to elm’s offsetLeft y = elm.offsetTop; //set elm to its offsetParent elm = elm.offsetParent; //use while loop to check if elm is null // if not then add current elm’s offsetLeft to x //offsetTop to y and set elm to its offsetParent while(elm != null) { y = parseInt(y) + parseInt(elm.offsetTop); elm = elm.offsetParent; } return y; } function Large(obj) { var imgbox=document.getElementById("imgbox"); imgbox.style.visibility='visible'; var img = document.createElement("img"); img.src=obj.src; img.style.width='200px'; img.style.height='200px'; if(img.addEventListener){ img.addEventListener('mouseout',Out,false); } else { img.attachEvent('onmouseout',Out); } imgbox.innerHTML=''; imgbox.appendChild(img); imgbox.style.left=(getElementLeft(obj)-50) +'px'; imgbox.style.top=(getElementTop(obj)-50) + 'px'; } function Out() { document.getElementById("imgbox").style.visibility='hidden'; }

Related: See More


Questions / Comments:

where is the design dude??

Mokshes () - 6 years ago - Reply 0