HTML code:
<!DOCTYPE HTML><HTML><Head> <Metahttp-equiv= "Content-type"content= "text/html; CHARSET=GBK"> <title>Single Picture Modal box</title> <Linkrel= "stylesheet"type= "Text/css"href= "Css/style.css"/> <Scriptsrc= "Js/jquery-3.2.0.min.js"></Script></Head><Body><Divclass= "Tuijianmenu-menu"> <Divclass= "Tuijianmenu-item"> <imgsrc= "Images/01.jpg"alt= "model Test Picture1"class= "Arealimg"> <!--Picture modal frame - <Divclass= "Motai"ID= "Mo"> <spanclass= "Close"ID= "Close">X</span> <imgclass= "Amotaiimg"src= "Motaiimg"ID= "Moimg"> <Divclass= "Acaption"ID= "caption"></Div> </Div> </Div> <Divclass= "Tuijianmenu-item"> <imgsrc= "Images/02.jpg"alt= "model Test Picture2"class= "Arealimg"> </Div> <Divclass= "Tuijianmenu-item"> <imgsrc= "Images/03.jpg"alt= "model Test Picture3"class= "Arealimg"> </Div> <Divclass= "Tuijianmenu-item"> <imgsrc= "Images/04.jpg"alt= "model Test Picture4"class= "Arealimg"> </Div></Div></Body></HTML>
JS Code:
<script type= "Text/javascript" >$ (document). Ready (function(){ $('. Tuijianmenu-item '). Click (function(e) {varimgsrc=$ ( This). Children ("img.arealimg"). attr (' src ')); varimgalt=$ ( This). Children ("img.arealimg"). attr (' Alt '); varCurrentdivid = $ (". Motai"). attr (' id ')); varcurrentcloseid=$ (". Motai. Close"). attr ("id"); varcurrentmoimgid=$ (". Motai img"). attr (' id ')); varcurrentcaptionid=$ (". Motai div"). attr (' id ')); varMotai=document.getElementById (Currentdivid); varmoimg=document.getElementById (Currentmoimgid); varcaption=document.getElementById (Currentcaptionid); Motai.style.display= "Block"; MOIMG.SRC=imgsrc; Caption.innerhtml=Imgalt; varClose=document.getElementById (Currentcloseid); $('. Motai. Close '). MouseDown (function() {Motai.style.display= "None"; }); }); });</script>
CSS code:
/*recommended Menu*/. Tuijianmenu-menu{width:100%;Height:210px;margin:20px Auto; }. Tuijianmenu-item{width:23%;margin:0 10px;float: Left;Height:200px;cursor:Pointer; }. Arealimg{margin:0;width:100%;Height:100%;Border-radius:6px; }. Arealimg:hover{Opacity:0.6; }. Motai{Display:None;width:100%;Height:100%;position:fixed;Overflow:Auto;Background-color:Rgba (0,0,0,0.7);Top:0; Left:0;Z-index: -; }. Amotaiimg{Display:Block;margin:25px Auto;width:50%;Max-width:750px; }. Acaption{text-align:Center;margin:15px Auto;width:60%;Max-height:750px;font-size:20px;Color:#ccc; }. Amotaiimg,.acaption{-webkit-animation:First 1s;-o-animation:First 1s;Animation:First 1s; }@keyframes First{From{transform:Scale (0.1);} to{Transform:Scale (1);}}. Close{font-size:40px;Font-weight:Bold;position:Absolute;Top:20px; Right:14%;Color:#f1f1f1; }. Close:hover,.close:focus{Color:#bbb;cursor:Pointer; }@media only screen and (max-width:750px){#moimg {width:100%; } } /*/Recommended Menu*/
In summary, there will be a beautiful picture Show code
Click:
JQUERY,CSS3 implementing multiple Picture modal frames