
开源代码如下:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>超甜辣妹壁纸下载 - 宋佳乐博客技术</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
<script>
// Tailwind自定义配置
tailwind.config = {
theme: {
extend: {
colors: {
primary: '#ff69b4', // 甜辣粉
secondary: '#2d3748', // 深灰
light: '#f8f9fa', // 浅灰
},
fontFamily: {
sans: ['Inter', 'system-ui', 'sans-serif'],
},
}
}
}
</script>
<style type="text/tailwindcss">
@layer utilities {
.wallpaper-card {
@apply relative rounded-lg overflow-hidden shadow-lg hover:shadow-2xl transition-all duration-300 cursor-pointer;
}
.wallpaper-card:hover .overlay {
@apply opacity-100;
}
.overlay {
@apply absolute inset-0 bg-black/50 flex items-center justify-center opacity-0 transition-opacity duration-300;
}
.modal {
@apply fixed inset-0 bg-black/80 flex items-center justify-center z-50 hidden;
}
.modal-content {
@apply max-w-4xl max-h-[90vh] relative;
}
/* 新增:壁纸图片容器样式 */
.wallpaper-img-container {
@apply w-full min-h-[200px] max-h-[600px] flex items-center justify-center bg-gray-200;
}
}
</style>
</head>
<body class="bg-gray-100 min-h-screen">
<!-- 头部导航 -->
<header class="bg-white shadow-md sticky top-0 z-40">
<div class="container mx-auto px-4 py-3 flex items-center justify-between">
<!-- Logo -->
<div class="flex items-center">
<img src="http://www.songjiale.com/img/logo.png" alt="logo" class="h-10 w-auto">
<h1 class="ml-3 text-xl font-bold text-primary">超甜辣妹壁纸</h1>
</div>
<!-- 导航菜单 -->
<nav>
<ul class="flex space-x-6">
<li><a href="#" class="text-secondary hover:text-primary font-medium">首页</a></li>
<li><a href="#" class="text-secondary hover:text-primary font-medium">热门壁纸</a></li>
<li><a href="#" class="text-secondary hover:text-primary font-medium">关于我们</a></li>
</ul>
</nav>
</div>
</header>
<!-- 主内容区 -->
<main class="container mx-auto px-4 py-8">
<!-- 页面介绍 -->
<section class="mb-8 text-center">
<h2 class="text-[clamp(1.8rem,4vw,2.5rem)] font-bold text-secondary mb-4">超甜辣妹壁纸合集</h2>
<p class="text-gray-600 max-w-2xl mx-auto mb-6">
这里汇集了全网最火的甜辣妹风格壁纸,每一张都精心挑选,适合手机、平板、电脑等各种设备使用。
喜欢的壁纸请<b>右键点击图片 → 选择"图片另存为"</b>即可下载保存哦~
</p>
<div class="inline-block bg-primary/10 text-primary px-4 py-2 rounded-full text-sm">
<i class="fa fa-heart mr-2"></i> 已更新 <?= rand(1000, 9999) ?>+ 张精美壁纸
</div>
</section>
<!-- 壁纸展示区 -->
<section class="mb-12">
<!-- 调整网格列数:根据图片比例优化,减少大屏下列数避免过窄 -->
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
<?php
// 获取当前页码,默认第1页
$page = isset($_GET['page']) ? max(1, intval($_GET['page'])) : 1;
$perPage = 20; // 每页数量调整:适配新布局,减少每页数量避免加载过慢
$totalPages = 10; // 模拟总页数,可根据实际需求调整
// 生成当前页的壁纸图片
for ($i = 1; $i <= $perPage; $i++) {
// 拼接API地址(添加随机参数避免缓存)
$imgUrl = "https://api.lolimi.cn/API/xjj/lt?rand=" . rand(100000, 999999);
?>
<div class="wallpaper-card" onclick="openModal('<?= $imgUrl ?>')">
<!-- 核心修改:替换固定高度为自适应容器 -->
<div class="wallpaper-img-container">
<img src="<?= $imgUrl ?>"
alt="辣妹壁纸<?= ($page-1)*$perPage + $i ?>"
class="max-w-full max-h-full object-contain">
</div>
<div class="overlay">
<div class="text-white text-center">
<i class="fa fa-search-plus text-2xl mb-2"></i>
<p class="text-sm">点击查看大图</p>
</div>
</div>
</div>
<?php } ?>
</div>
</section>
<!-- 分页控件 -->
<section class="flex justify-center">
<nav class="flex items-center space-x-2">
<?php if ($page > 1): ?>
<a href="?page=<?= $page-1 ?>" class="px-4 py-2 bg-white border border-gray-300 rounded hover:bg-primary hover:text-white transition-colors">
<i class="fa fa-chevron-left"></i> 上一页
</a>
<?php endif; ?>
<span class="px-4 py-2 bg-primary text-white rounded">
第 <?= $page ?> 页 / 共 <?= $totalPages ?> 页
</span>
<?php if ($page < $totalPages): ?>
<a href="?page=<?= $page+1 ?>" class="px-4 py-2 bg-white border border-gray-300 rounded hover:bg-primary hover:text-white transition-colors">
下一页 <i class="fa fa-chevron-right"></i>
</a>
<?php endif; ?>
</nav>
</section>
</main>
<!-- 图片放大模态框 -->
<div id="imageModal" class="modal">
<div class="modal-content">
<span onclick="closeModal()" class="absolute top-4 right-4 text-white text-3xl cursor-pointer hover:text-primary">×</span>
<img id="modalImage" src="" alt="大图预览" class="max-w-full max-h-[90vh]">
</div>
</div>
<!-- 底部信息 -->
<footer class="bg-secondary text-white py-6">
<div class="container mx-auto px-4 text-center">
<p>© <?= date('Y') ?> 宋佳乐博客技术支持</p>
<p class="text-sm text-gray-400 mt-2">
<i class="fa fa-info-circle mr-1"></i> 所有壁纸仅供个人欣赏使用,请勿用于商业用途
</p>
</div>
</footer>
<!-- JavaScript -->
<script>
// 打开图片放大模态框
function openModal(imgUrl) {
const modal = document.getElementById('imageModal');
const modalImage = document.getElementById('modalImage');
modalImage.src = imgUrl;
modal.style.display = 'flex';
// 点击模态框背景关闭
modal.onclick = function(e) {
if (e.target === modal) {
closeModal();
}
}
// 按ESC键关闭
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
closeModal();
}
});
}
// 关闭图片放大模态框
function closeModal() {
const modal = document.getElementById('imageModal');
modal.style.display = 'none';
}
// 页面加载完成后的提示
window.onload = function() {
console.log('超甜辣妹壁纸网站加载完成~');
}
</script>
</body>
</html>
