hexo-theme-halunhaku
Version:
A modern, responsive Hexo theme with enhanced code blocks, perfect cover images, and Chinese text optimization. Production-ready with mobile-first design.
270 lines (234 loc) • 7.31 kB
CSS
/* 封面图片专用样式 - 确保完整显示 */
/* 重置默认的封面样式,确保完整显示 */
.post-cover-container {
background: linear-gradient(135deg, var(--secondary-color) 0%, rgba(var(--secondary-color), 0.8) 100%) ;
border: 1px solid var(--border-color) ;
position: relative ;
display: flex ;
align-items: center ;
justify-content: center ;
min-height: 300px ;
max-height: 500px ;
overflow: hidden ;
}
/* 文章详情页封面图片 - 完整显示不裁剪 */
.post-cover-image {
/* 确保图片完整显示,不被裁剪 */
object-fit: contain ;
object-position: center ;
/* 添加内边距,避免图片贴边 */
padding: 10px ;
/* 确保图片不会超出容器 */
max-width: calc(100% - 20px) ;
max-height: calc(100% - 20px) ;
/* 居中显示 */
margin: auto ;
display: block ;
/* 保持宽高比 */
width: auto ;
height: auto ;
}
/* 首页文章卡片封面容器 - 强制样式 */
.post-card-cover {
background-color: var(--secondary-color) ;
border: 1px solid var(--border-color) ;
position: relative ;
overflow: hidden ;
display: flex ;
align-items: center ;
justify-content: center ;
min-height: 200px ;
aspect-ratio: 3/2 ;
}
/* 首页文章卡片封面图片 - 完整显示不裁剪 */
.post-card-cover-image {
object-fit: contain ;
object-position: center ;
transition: all 0.3s ease ;
padding: 8px ;
max-width: calc(100% - 16px) ;
max-height: calc(100% - 16px) ;
display: block ;
margin: auto ;
width: auto ;
height: auto ;
}
/* 覆盖可能的Tailwind样式冲突 */
.aspect-\[3\/2\] .post-card-cover-image {
object-fit: contain ;
}
/* 确保背景图片方式被完全禁用 */
.post-card-cover[style*="background-image"] {
background-image: none ;
background-size: auto ;
background-position: center ;
background-repeat: no-repeat ;
}
/* 悬停效果 */
.post-cover-image:hover {
transform: scale(1.01) ;
box-shadow: 0 15px 35px -10px rgba(0, 0, 0, 0.2) ;
}
.group:hover .post-card-cover-image {
transform: scale(1.02) ;
}
/* 响应式调整 */
@media (max-width: 768px) {
.post-cover-container {
min-height: 200px ;
max-height: 300px ;
}
.post-cover-image {
padding: 8px ;
max-width: calc(100% - 16px) ;
max-height: calc(100% - 16px) ;
}
.post-card-cover {
min-height: 150px ;
aspect-ratio: 3/2 ;
}
.post-card-cover-image {
padding: 6px ;
max-width: calc(100% - 12px) ;
max-height: calc(100% - 12px) ;
}
}
@media (max-width: 480px) {
.post-cover-container {
min-height: 180px ;
max-height: 250px ;
}
.post-cover-image {
padding: 6px ;
max-width: calc(100% - 12px) ;
max-height: calc(100% - 12px) ;
}
.post-card-cover-image {
padding: 4px ;
max-width: calc(100% - 8px) ;
max-height: calc(100% - 8px) ;
}
}
/* 加载状态优化 */
.post-cover-image[style*="opacity: 0"],
.post-card-cover-image[style*="opacity: 0"] {
background: linear-gradient(90deg,
var(--secondary-color) 25%,
rgba(var(--secondary-color), 0.8) 50%,
var(--secondary-color) 75%);
background-size: 200% 100%;
animation: loading 1.5s infinite;
}
@keyframes loading {
0% {
background-position: 200% 0;
}
100% {
background-position: -200% 0;
}
}
/* 图片加载失败时的样式 */
.post-cover-image:not([src]),
.post-cover-image[src=""],
.post-cover-image[src="#"],
.post-card-cover-image:not([src]),
.post-card-cover-image[src=""],
.post-card-cover-image[src="#"] {
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
display: flex ;
align-items: center ;
justify-content: center ;
color: white;
font-size: 2rem;
opacity: 0.7;
min-height: 100px;
}
.post-cover-image:not([src])::before,
.post-cover-image[src=""]::before,
.post-cover-image[src="#"]::before,
.post-card-cover-image:not([src])::before,
.post-card-cover-image[src=""]::before,
.post-card-cover-image[src="#"]::before {
content: "🖼️";
font-size: 3rem;
}
/* 深色模式优化 */
@media (prefers-color-scheme: dark) {
.post-cover-container {
background: linear-gradient(135deg, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.1) 100%) ;
border-color: rgba(255, 255, 255, 0.1) ;
}
.post-card-cover {
background-color: rgba(0, 0, 0, 0.2) ;
border-color: rgba(255, 255, 255, 0.1) ;
}
}
/* 确保Tailwind的aspect-ratio正常工作 */
.aspect-\[3\/2\] {
aspect-ratio: 3/2 ;
}
/* 强制覆盖可能冲突的样式 */
.post-cover-container .post-cover-image {
object-fit: contain ;
}
.post-card-cover .post-card-cover-image {
object-fit: contain ;
}
/* 无障碍优化 */
@media (prefers-reduced-motion: reduce) {
.post-cover-image,
.post-card-cover-image {
transition: none ;
}
.post-cover-image:hover,
.post-card-cover-image:hover,
.group:hover .post-card-cover-image {
transform: none ;
}
}
/* 打印样式 */
@media print {
.post-cover-container,
.post-card-cover {
box-shadow: none ;
border: 1px solid #ccc ;
background: white ;
}
.post-cover-image,
.post-card-cover-image {
box-shadow: none ;
}
}
/* 最高优先级规则 - 确保首页封面完整显示 */
article.group .post-card-cover {
background-image: none ;
background-size: auto ;
display: flex ;
align-items: center ;
justify-content: center ;
}
article.group .post-card-cover img,
article.group .post-card-cover .post-card-cover-image {
object-fit: contain ;
object-position: center ;
max-width: calc(100% - 16px) ;
max-height: calc(100% - 16px) ;
width: auto ;
height: auto ;
display: block ;
margin: auto ;
}
/* 覆盖任何可能的背景图片样式 */
.group > div > div[style*="background-image"] {
background-image: none ;
display: flex ;
align-items: center ;
justify-content: center ;
}
/* 确保aspect-ratio容器正确工作 */
.aspect-\[3\/2\] {
aspect-ratio: 3/2 ;
display: flex ;
align-items: center ;
justify-content: center ;
}