rewrite gallery 2
by bvotcode
HTML
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div class="allitems"></div>
CSS
* {
box-sizing: border-box;
}
.galleryrow > .gallerycolumn {
padding: 0 8px;
}
.galleryrow:after {
content: "";
display: table;
clear: both;
}
.gallerycolumn {
float: left;
width: 25%;
}
/* The Modal (background) */
.gallerymodal {
display: none;
position: fixed;
z-index: 1;
padding-top: 100px;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: black;
}
/* Modal Content */
.gallerymodal-content {
position: relative;
background-color: #fefefe;
margin: auto;
padding: 0;
width: 90%;
max-width: 1200px;
}
/* The Close Button */
.galleryclose {
color: white;
position: absolute;
top: 10px;
right: 25px;
font-size: 35px;
font-weight: bold;
}
.galleryclose:hover,
.galleryclose:focus {
color: #999;
text-decoration: none;
cursor: pointer;
}
.gallerymySlides {
display: none;
}
.gallerycursor {
cursor: pointer;
}
/* Next & previous buttons */
.galleryprev,
.gallerynext {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
padding: 16px;
margin-top: -50px;
color: red;
font-weight: bold;
font-size: 20px;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
user-select: none;
-webkit-user-select: none;
}
/* Position the "next button" to the right */
.gallerynext {
right: 0;
border-radius: 3px 0 0 3px;
}
/* On hover, add a black background color with a little bit see-through */
.galleryprev:hover,
.gallerynext:hover {
background-color: rgba(0, 0, 0, 0.8);
}
/* Number text (1/3 etc) */
.gallerynumbertext {
color: #f2f2f2;
font-size: 12px;
padding: 8px 12px;
position: absolute;
top: 0;
}
.gallerycaption-container {
text-align: center;
background-color: black;
padding: 2px 16px;
color: white;
}
.gallerydemo {
opacity: 0.6;
}
.galleryactive,
.gallerydemo:hover {
opacity: 1;
}
img.galleryhover-shadow {
transition: 0.3s;
}
.galleryhover-shadow:hover {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0...
JavaScript
var json = {
"GalleryItem": [{
"ImageName": "AAA AAA",
"ImageNumber":"1",
"ImageSlide": "gallerycurrentSlide(1)",
"OpenandSlide": "galleryopenModal();gallerycurrentSlide(1)",
"ImageLink": "https://i.imgur.com/Apz96Sa.png"
}, {
"ImageName": "BBB BBB",
"ImageNumber":"2",
"ImageSlide": "gallerycurrentSlide(2)",
"OpenandSlide": "galleryopenModal();gallerycurrentSlide(2)",
"ImageLink": "https://i.imgur.com/LOQjVCz.png"
}, {
"ImageName": "CCC CCC",
"ImageNumber":"3",
"ImageSlide": "gallerycurrentSlide(3)",
"OpenandSlide": "galleryopenModal();gallerycurrentSlide(3)",
"ImageLink": "https://i.imgur.com/izyiuJ6.png"
}, {
"ImageName": "DDD DDD",
"ImageNumber":"4",
"ImageSlide": "gallerycurrentSlide(4)",
"OpenandSlide": "galleryopenModal();gallerycurrentSlide(4)",
"ImageLink": "https://i.imgur.com/eJqEsnz.png"
}]
};
function galleryandslider(json){
var outputA = ""; // initialize it outside the loop
$.each(json.GalleryItem,function()
{
outputA += '<div class="gallerycolumn"> <img class="galleryhover-shadow gallerycursor" src= "'+this.ImageLink+'" style="width:50%" onclick="'+this.OpenandSlide+'"></div>';
});
var endoutputA = '<div class="galleryrow"> '+outputA+' </div>'
$('.itemsA').append(endoutputA);
//console.log(endoutputA)
var outputB = ""; // initialize it outside the loop
$.each(json.GalleryItem,function()
{
outputB += '<div class="gallerymySlides"> <div class="gallerynumbertext"> '+this.ImageNumber+'</div><img class="imageinpopupcenter" src= "'+this.ImageLink+'" style="width:80%" ></div>';
});
var endoutputB = '<div id="gallerymyModal" class="gallerymodal"><span class="galleryclose gallerycursor" onclick="gallerycloseModal()">×</span><div class="gallerymodal-content"> '+outputB+' '
//$('.itemsB').append(endoutputB);
var...