Image popup

This commit is contained in:
Andrei Astafev 2019-04-21 12:12:43 +03:00
parent 04a2dcca22
commit 947c137b2c
4 changed files with 69 additions and 0 deletions

View File

@ -329,3 +329,50 @@ pre, code, kbd, samp
.panel {
padding-bottom: 12px;
}
.popup{
width: 900px;
margin: auto;
text-align: center
}
.popup img{
width: 200px;
height: 200px;
cursor: pointer
}
.show{
z-index: 999;
display: none;
}
.show .overlay{
width: 100%;
height: 100%;
background: rgba(0,0,0,.66);
position: absolute;
top: 0;
left: 0;
}
.show .img-show{
width: 600px;
height: 400px;
background: #FFF;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
overflow: hidden
}
.img-show span{
position: absolute;
top: 10px;
right: 10px;
z-index: 99;
cursor: pointer;
}
.img-show img{
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}

14
static/js/image-popup.js Normal file
View File

@ -0,0 +1,14 @@
$(function () {
"use strict";
$(".popup img").click(function () {
var $src = $(this).attr("src");
$(".show").fadeIn();
$(".img-show img").attr("src", $src);
});
$("span, .overlay").click(function () {
$(".show").fadeOut();
});
});

View File

@ -87,6 +87,13 @@
</div>
{{ article.content }}
</div>
<div class="show">
<div class="overlay"></div>
<div class="img-show">
<span>X</span>
<img src="">
</div>
</div>
<!-- /.entry-content -->
{% include 'includes/related-posts.html' %}
{% include 'includes/series.html' %}

View File

@ -265,6 +265,7 @@
{% if BANNER %}
<script src="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/js/bodypadding.js"></script>
{% endif %}
<script src="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/js/image-popup.js"></script>
{% include 'includes/sidebar/github-js.html' %}
{% include 'includes/disqus_script.html' %}
{% include 'includes/ga.html' %}