Can you help me understand why this code is working fine in CodePen, but not on my HTML page? I'm unable to identify the error that may have occurred. Any assistance would be greatly appreciated! I suspect there's an issue with connecting some jQuery modules...I've tried fixing it and connecting some of them without success. The CSS and HTML are functioning properly, but I'm unable to display an image.
Ultimately, I've decided to share the entire code from my HTML page. Unfortunately, removing the 's' character in https and changing the way jQuery is connected did not resolve the issue...
Update: Problem solved! The reason the code wasn't working was due to Bootstrap. I needed to link a specific Bootstrap URL to my code, which fixed the problem. https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'> https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.1/animate.min.css'
<!DOCTYPE html>
<html lang="en">
<head>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.min.js">
</script>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div class="container">
<div class="gallery">
<img src="https://img.buzzfeed.com/buzzfeed-static/static/2015-08/11/14/enhanced/webdr01/original-9161-1439317330-3.jpg?downsize=715:*&output-format=auto&output-quality=auto" alt="" width="100%" height="auto" class="gallery-img" />
<img src="https://img.buzzfeed.com/buzzfeed-static/static/2015-08/11/14/enhanced/webdr08/original-1654-1439317465-3.jpg?downsize=715:*&output-format=auto&output-quality=auto" alt="" width="100%" height="auto" class="gallery-img" />
<img src="https://img.buzzfeed.com/buzzfeed-static/static/2015-08/11/15/enhanced/webdr08/original-13354-1439321173-3.jpg?downsize=715:*&output-format=auto&output-quality=auto" alt="" width="100%" height="auto" class="gallery-img" />
<img src="https://img.buzzfeed.com/buzzfeed-static/static/2015-08/11/15/enhanced/webdr04/original-25740-1439321209-5.jpg?downsize=715:*&output-format=auto&output-quality=auto" alt="" width="100%" height="auto" class="gallery-img" />
<img src="https://img.buzzfeed.com/buzzfeed-static/static/2015-08/11/15/enhanced/webdr08/original-9292-1439319916-3.jpg?downsize=715:*&output-format=auto&output-quality=auto" alt="" width="100%" height="auto" class="gallery-img" />
<img src="https://img.buzzfeed.com/buzzfeed-static/static/2015-08/11/14/enhanced/webdr05/original-6710-1439319334-17.jpg?downsize=715:*&output-format=auto&output-quality=auto" alt="" width="100%" height="auto" class="gallery-img" />
<img src="https://img.buzzfeed.com/buzzfeed-static/static/2015-08/11/15/enhanced/webdr02/original-16901-1439320287-3.jpg?downsize=715:*&output-format=auto&output-quality=auto" alt="" width="100%" height="auto" class="gallery-img" />
<img src="https://img.buzzfeed.com/buzzfeed-static/static/2015-08/11/15/enhanced/webdr04/original-29345-1439321306-8.jpg?downsize=715:*&output-format=auto&output-quality=auto" alt="" width="100%" height="auto" class="gallery-img" />
<img src="https://img.buzzfeed.com/buzzfeed-static/static/2015-08/11/15/enhanced/webdr15/original-20286-1439320376-10.jpg?downsize=715:*&output-format=auto&output-quality=auto" alt="" width="100%" height="auto" class="gallery-img" />
<img src="https://img.buzzfeed.com/buzzfeed-static/static/2015-08/11/14/enhanced/webdr02/original-6989-1439317507-15.jpg?downsize=715:*&output-format=auto&output-quality=auto" alt="" width="100%" height="auto" class="gallery-img" />
<img src="https://img.buzzfeed.com/buzzfeed-static/static/2015-08/11/14/enhanced/webdr11/original-8867-1439317446-6.jpg?downsize=715:*&output-format=auto&output-quality=auto" alt="" width="100%" height="auto" class="gallery-img" />
<img src="https://img.buzzfeed.com/buzzfeed-static/static/2015-08/11/14/enhanced/webdr03/original-22498-1439319085-3.jpg?downsize=715:*&output-format=auto&output-quality=auto" alt="" width="100%" height="auto" class="gallery-img" />
</div>
</div>
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
</div>
</div>
</div>
</div>
<style>
.gallery {
-webkit-column-count: 3;
-moz-column-count: 3;
column-count: 3;
-webkit-column-gap: 10px;
-moz-column-gap: 10px;
column-gap: 10px;
margin-top: 10px;
overflow: hidden;
}
.gallery img {
width: 100%;
height: auto;
transition: 500ms;
margin-bottom: 10px;
opacity: 0.8;
page-break-inside: avoid; /* For Firefox. */
-webkit-column-break-inside: avoid; /* For Chrome & friends. */
break-inside: avoid; /* For standard browsers like IE. :-) */
}
.gallery img:hover {
opacity: 1;
}
.modal-img,.model-vid{
width:100%;
height: auto;
}
.modal-body{
padding:0px;
}
.modal-dialog {
text-align: center;
vertical-align: middle;
display: block;
top: 10%;
}
.modal-content {
border: none;
}
@media screen and (max-width: 767px) {
.gallery {
-webkit-column-count: 2;
-moz-column-count: 2;
column-count: 2;
}
.gallery div { margin: 0;
width: 200px;
}
}
@media screen and (max-width: 479px) {
.gallery {
-webkit-column-count: 1;
-moz-column-count: 1;
column-count: 1;
}
.gallery div {
margin: 0;
width: 200px;
}
}
</style>
<script>
$(document).ready(function () {
$(".gallery-img").click(function(){
var t = $(this).attr("src");
$(".modal-body").html("<img src='"+t+"' class='modal-img'>");
$("#myModal").modal();
});
});
</script>
</body>
</html>