Files
FlexPhoto/style.css

59 lines
1.7 KiB
CSS
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
:root{
--gap: 10px; /* 把间距也抽成变量,方便统一修改 */
}
.flexphoto {
display: flex;
gap: var(--gap); /* 使用变量统一控制间距 */
flex-wrap: wrap;
padding: 0;
margin: 10px 0;
/* 缩略图统一裁切比例:每排高度一致,改这里即可(如 3 / 2、16 / 9、1 / 1) */
--flexphoto-ratio: 4 / 3;
}
.flexphoto figure {
margin: 0 !important;
flex: 1;
min-width: 0;
display: flex; /* 让内部的 a 撑满整块,整行高度由 flex 拉伸统一 */
aspect-ratio: var(--flexphoto-ratio); /* 统一比例,图片按 cover 裁切 */
}
/* 点击放大的触发层(Fancybox 绑定在 a.flexphoto-link 上) */
.flexphoto .flexphoto-link,
.flexphoto .flexphoto-link:hover {
display: flex; /* 同时作为 img 的容器,让 img 拉伸填满 */
flex: 1;
min-width: 0;
cursor: zoom-in;
text-decoration: none; /* 屏蔽主题 a:hover 的点状下划线 */
}
.flexphoto figure img{
height: 100%;
width: 100%;
object-fit: cover;
max-height: 100%;
}
.flexphoto.diycol figure {
flex: none;
/* 正确计算宽度:100%均分 - 分摊的间距 */
width: calc((100% / var(--col-num)) - (var(--gap) * (var(--col-num) - 1) / var(--col-num)));
/* 关键:给figure设置最小高度,避免img的height:100%无参考 */
}
.flexphoto.diycol{
--col-num: var(--desktop-col, 4);
}
/* 平板端(≤1024px):读取data-tablet-col */
@media (max-width: 1024px) {
.flexphoto.diycol {
--col-num: var(--tablet-col, 3);
}
}
/* 手机端(≤768px):读取data-mobile-col */
@media (max-width: 768px) {
.flexphoto.diycol {
--col-num: var(--mobile-col, 2);
}
}