feat(lightbox): 接入全站图片预览
This commit is contained in:
@@ -237,18 +237,26 @@ body.aksrt-body-scroll .aksrt-show-on-scroll {
|
||||
/* ============================================================
|
||||
* 5. 图片灯箱
|
||||
* ============================================================ */
|
||||
[data-aksrt-lightbox="1"] img:not(.no-imgbox):not(.no-lightbox),
|
||||
.aksrt-lightbox-trigger img:not(.no-imgbox):not(.no-lightbox),
|
||||
.imgbox-container img:not(.no-imgbox):not(.no-lightbox),
|
||||
.comment-content .box-img {
|
||||
cursor: zoom-in;
|
||||
}
|
||||
|
||||
.aksrt-lightbox {
|
||||
--imgbox-origin-left: 50vw;
|
||||
--imgbox-origin-top: 50vh;
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 9999;
|
||||
background: rgba(0, 0, 0, 0.85);
|
||||
z-index: 100000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(0, 0, 0, 0.88);
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition: opacity 0.3s, visibility 0.3s;
|
||||
cursor: zoom-out;
|
||||
transition: opacity 0.25s ease, visibility 0.25s ease;
|
||||
}
|
||||
|
||||
.aksrt-lightbox.is-open {
|
||||
@@ -256,73 +264,103 @@ body.aksrt-body-scroll .aksrt-show-on-scroll {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__img {
|
||||
max-width: 90vw;
|
||||
max-height: 85vh;
|
||||
object-fit: contain;
|
||||
border-radius: 4px;
|
||||
transform: scale(0.9);
|
||||
transition: transform 0.3s;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.aksrt-lightbox.is-open .aksrt-lightbox__img {
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
.aksrt-lightbox__close {
|
||||
.aksrt-lightbox__stage {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
right: 16px;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
color: #fff;
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
inset: 64px 72px 82px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: background 0.2s;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__close:hover {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
.aksrt-lightbox__img {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
width: auto;
|
||||
height: auto;
|
||||
object-fit: contain;
|
||||
transform: scale(1);
|
||||
transform-origin: center;
|
||||
transition: transform 0.25s ease, opacity 0.2s ease;
|
||||
cursor: zoom-in;
|
||||
user-select: none;
|
||||
-webkit-user-drag: none;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__caption {
|
||||
.aksrt-lightbox.from-origin.is-open .aksrt-lightbox__img {
|
||||
animation: aksrt-lightbox-enter 0.3s ease both;
|
||||
}
|
||||
|
||||
.aksrt-lightbox.is-zoomed .aksrt-lightbox__img {
|
||||
cursor: zoom-out;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__toolbar {
|
||||
position: absolute;
|
||||
bottom: 16px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
z-index: 3;
|
||||
top: 14px;
|
||||
right: 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__tool,
|
||||
.aksrt-lightbox__nav {
|
||||
border: 0;
|
||||
background: rgba(255, 255, 255, 0.14);
|
||||
color: #fff;
|
||||
box-shadow: none;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s ease, transform 0.2s ease;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__tool {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
padding: 0;
|
||||
border-radius: 999px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__tool:hover,
|
||||
.aksrt-lightbox__tool:focus-visible,
|
||||
.aksrt-lightbox__nav:hover,
|
||||
.aksrt-lightbox__nav:focus-visible {
|
||||
background: rgba(255, 255, 255, 0.28);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__tool:focus-visible,
|
||||
.aksrt-lightbox__nav:focus-visible,
|
||||
.aksrt-lightbox__thumb:focus-visible {
|
||||
outline: 2px solid #fff;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__counter {
|
||||
min-width: 48px;
|
||||
color: rgba(255, 255, 255, 0.84);
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
max-width: 80%;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__nav {
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
color: #fff;
|
||||
font-size: 24px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__nav:hover {
|
||||
background: rgba(255, 255, 255, 0.25);
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 999px;
|
||||
font-size: 22px;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
.aksrt-lightbox__nav--prev {
|
||||
@@ -333,38 +371,120 @@ body.aksrt-body-scroll .aksrt-show-on-scroll {
|
||||
right: 16px;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__counter {
|
||||
.aksrt-lightbox__caption {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
left: 16px;
|
||||
color: rgba(255, 255, 255, 0.7);
|
||||
z-index: 2;
|
||||
right: 20px;
|
||||
bottom: 18px;
|
||||
left: 20px;
|
||||
color: rgba(255, 255, 255, 0.88);
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
text-align: center;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__download {
|
||||
.aksrt-lightbox__thumbs {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
right: 64px;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
color: #fff;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
z-index: 3;
|
||||
right: 50%;
|
||||
bottom: 18px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: background 0.2s;
|
||||
gap: 8px;
|
||||
max-width: min(70vw, 760px);
|
||||
padding: 6px;
|
||||
overflow-x: auto;
|
||||
border-radius: 8px;
|
||||
background: rgba(0, 0, 0, 0.38);
|
||||
transform: translateX(50%);
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__download:hover {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
.aksrt-lightbox__thumb {
|
||||
flex: 0 0 auto;
|
||||
width: 56px;
|
||||
height: 44px;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
border: 2px solid transparent;
|
||||
border-radius: 5px;
|
||||
background: transparent;
|
||||
opacity: 0.6;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* 可缩放图片的光标 */
|
||||
.aksrt-cursor-zoom-in {
|
||||
cursor: zoom-in;
|
||||
.aksrt-lightbox__thumb.is-active {
|
||||
border-color: #fff;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__thumb img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__thumbs:not([hidden]) ~ .aksrt-lightbox__caption {
|
||||
bottom: 78px;
|
||||
}
|
||||
|
||||
.aksrt-lightbox [hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
@keyframes aksrt-lightbox-enter {
|
||||
from {
|
||||
transform-origin: var(--imgbox-origin-left) var(--imgbox-origin-top);
|
||||
transform: scale(0.82);
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform-origin: center;
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.aksrt-lightbox__stage {
|
||||
inset: 58px 10px 78px;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__toolbar {
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__tool {
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__counter {
|
||||
min-width: 36px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__nav {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
font-size: 18px;
|
||||
background: rgba(0, 0, 0, 0.34);
|
||||
}
|
||||
|
||||
.aksrt-lightbox__nav--prev {
|
||||
left: 8px;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__nav--next {
|
||||
right: 8px;
|
||||
}
|
||||
|
||||
.aksrt-lightbox__thumbs {
|
||||
max-width: calc(100vw - 20px);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user