img-lightbox
Version:
Responsive no-jQuery pure JS/CSS Lightbox for images, no dependencies, 10kb unminified source code, with demo
291 lines (257 loc) • 5.01 kB
CSS
/*!
* some animations from animate.css
* @see {@link https://github.com/daneden/animate.css}
* daneden.github.io/animate.css/
*/
/* .animated {
animation-duration: 2s;
animation-fill-mode: both;
} */
@-webkit-keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.fadeIn {
-webkit-animation-name: fadeIn;
animation-name: fadeIn;
}
@-webkit-keyframes fadeInUp {
0% {
opacity: 0;
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
}
100% {
opacity: 1;
-webkit-transform: none;
transform: none;
}
}
@keyframes fadeInUp {
0% {
opacity: 0;
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
}
100% {
opacity: 1;
-webkit-transform: none;
transform: none;
}
}
.fadeInUp {
-webkit-animation-name: fadeInUp;
animation-name: fadeInUp;
}
@-webkit-keyframes fadeOut {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
@keyframes fadeOut {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
.fadeOut {
-webkit-animation-name: fadeOut;
animation-name: fadeOut;
}
@-webkit-keyframes fadeOutDown {
0% {
opacity: 1;
}
100% {
opacity: 0;
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
}
}
@keyframes fadeOutDown {
0% {
opacity: 1;
}
100% {
opacity: 0;
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
}
}
.fadeOutDown {
-webkit-animation-name: fadeOutDown;
animation-name: fadeOutDown;
}
/*!
* img lightbox
*/
.img-lightbox {
display: none;
opacity: 0;
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.92);
z-index: 999999;
}
.img-lightbox img {
display: block;
opacity: 0;
max-width: 90%;
max-height: 90%;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: transparent;
border: 0;
-webkit-box-shadow: 0.267rem 0.267rem 0.267rem 0 rgba(3, 3, 3, 0.3);
box-shadow: 0.267rem 0.267rem 0.267rem 0 rgba(3, 3, 3, 0.3);
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
cursor: -webkit-zoom-out;
cursor: zoom-out;
margin: auto;
}
/*!
* reset for animate.css
* daneden.github.io/animate.css/
*/
.img-lightbox.animated,
.img-lightbox img.animated {
-webkit-animation-duration: 0.4s;
animation-duration: 0.4s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
/*!
* another pure css spinner
* @see {@link https://epic-spinners.epicmax.co/}
*/
.img-lightbox .half-circle-spinner,
.img-lightbox .half-circle-spinner * {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.img-lightbox .half-circle-spinner {
width: 60px;
height: 60px;
border-radius: 100%;
position: relative;
margin: 0;
position: fixed;
top: 50%;
left: 50%;
margin-right: -50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.img-lightbox .half-circle-spinner .circle {
content: "";
position: absolute;
width: 100%;
height: 100%;
border-radius: 100%;
border: calc(60px / 10) solid transparent;
}
.img-lightbox .half-circle-spinner .circle.circle-1 {
border-top-color: #FFFFFF;
-webkit-animation: half-circle-spinner-animation 1s infinite;
animation: half-circle-spinner-animation 1s infinite;
}
.img-lightbox .half-circle-spinner .circle.circle-2 {
border-bottom-color: #FFFFFF;
-webkit-animation: half-circle-spinner-animation 1s infinite alternate;
animation: half-circle-spinner-animation 1s infinite alternate;
}
@-webkit-keyframes half-circle-spinner-animation {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@keyframes half-circle-spinner-animation {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
.img-lightbox.is-loaded .half-circle-spinner {
display: none;
}
.img-lightbox .btn-close {
display: block;
position: fixed;
top: 1.000rem;
right: 1.000rem;
width: 1.500rem;
height: 1.500rem;
font-size: 1.000rem;
outline: none;
cursor: pointer;
border: 0;
background-color: transparent;
}
/*!
* pure css version
* @see {@link https://codepen.io/brissmyr/pen/egidw}
*/
.img-lightbox .btn-close:before,
.img-lightbox .btn-close:after {
content: " ";
width: 0.125em;
height: 1.500em;
position: absolute;
top: 0;
right: 0.688em;
background-color: #FFFFFF;
}
.img-lightbox .btn-close:before {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
.img-lightbox .btn-close:after {
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
}
/*!
* @see {@link https://github.com/englishextra/iframe-lightbox/issues/12}
*/
.img-lightbox--open {
overflow: hidden;
-webkit-overflow-scrolling: touch;
-ms-touch-action: auto;
touch-action: auto;
height: auto;
}