commit 1ddd1d10478c8997f11b00175f30ea521e78d033
Author: Cx330 <1487537121@qq.com>
Date: Tue Feb 25 02:41:59 2025 +0000
上传文件至 /
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..efbecda
--- /dev/null
+++ b/index.html
@@ -0,0 +1,164 @@
+
+
+
+
+
+ DreamLife|ToolBox
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/scripts.js b/scripts.js
new file mode 100644
index 0000000..433e4cd
--- /dev/null
+++ b/scripts.js
@@ -0,0 +1,209 @@
+const searchBox = document.getElementById('search-input'); // 使用不同的名称避免重复声明
+const fullButton = document.getElementById('fullscreen-button');
+
+// 监听滚动事件
+window.addEventListener('scroll', function() {
+ const scrollTop = window.scrollY || document.documentElement.scrollTop; // 获取滚动的距离
+
+ if (scrollTop > 50) { // 当页面滚动超过50px时
+ searchBox.style.top = '-50px'; // 将搜索框移出视口
+ fullscreenButton.style.top = '-50px'; // 让全屏按钮同步隐藏
+ } else {
+ searchBox.style.top = '10px'; // 恢复到初始位置
+ fullscreenButton.style.top = '0px'; // 让全屏按钮同步恢复
+ }
+});
+
+// 获取按钮和侧边栏元素
+const menuButton = document.querySelector('.toggle-menu');
+const sidebar = document.getElementById('sidebar');
+
+// 侧边栏切换功能
+menuButton.addEventListener('click', function(event) {
+ event.stopPropagation(); // 阻止事件冒泡,避免触发文档点击事件
+ toggleSidebar(); // 调用切换侧边栏函数
+ toggleRotation(); // 调用旋转按钮函数
+});
+
+// 侧边栏元素和按钮
+function toggleSidebar() {
+ sidebar.classList.toggle('open'); // 切换侧边栏的显示/隐藏
+ if (sidebar.classList.contains('open')) {
+ document.body.classList.add('no-scroll'); // 禁用滚动
+ } else {
+ document.body.classList.remove('no-scroll'); // 恢复滚动
+ }
+}
+
+// 检查侧边栏的状态,更新按钮显示/隐藏
+function updateMenuButtonVisibility() {
+ if (window.innerWidth <= 768) { // 小屏幕显示菜单按钮
+ menuButton.style.display = 'block';
+ } else { // 大屏幕上不显示菜单按钮,侧边栏始终可见
+ menuButton.style.display = 'none';
+ if (sidebar.classList.contains('open')) {
+ sidebar.classList.add('open');
+ }
+ }
+}
+
+// 监听窗口大小变化,确保菜单按钮的显示和隐藏正确
+window.addEventListener('resize', function() {
+ updateMenuButtonVisibility();
+});
+
+// 初始化时检查菜单按钮的显示状态
+updateMenuButtonVisibility();
+
+// 监听点击事件,点击侧边栏外部区域关闭侧边栏
+document.addEventListener('click', function(event) {
+ const isClickInsideSidebar = sidebar.contains(event.target);
+ const isClickInsideButton = menuButton.contains(event.target);
+
+ // 如果点击的地方不在侧边栏和按钮内部,并且侧边栏是打开的,则关闭侧边栏
+ if (!isClickInsideSidebar && !isClickInsideButton && sidebar.classList.contains('open')) {
+ sidebar.classList.remove('open'); // 关闭侧边栏
+ menuButton.classList.remove('rotated'); // 恢复按钮横向
+ document.body.classList.remove('no-scroll'); // 允许滚动
+ }
+});
+
+// 阻止点击侧边栏时关闭侧边栏
+sidebar.addEventListener('click', function(event) {
+ event.stopPropagation(); // 阻止事件冒泡,防止点击侧边栏时关闭
+});
+
+// 动画效果
+function animateToolCards() {
+ const toolCards = document.querySelectorAll('.tool-card');
+ toolCards.forEach((card, index) => {
+ card.style.transitionDelay = `${index * 100}ms`; // 按顺序延迟动画
+ card.classList.add('animated'); // 添加动画类
+ });
+}
+;
+
+// 禁用双指缩放
+document.addEventListener('touchstart', function(e) {
+ if (e.touches.length > 1) { // 如果检测到多于一个手指
+ e.preventDefault(); // 阻止默认缩放行为
+ }
+});
+
+document.addEventListener('touchmove', function(e) {
+ if (e.touches.length > 1) { // 如果检测到多于一个手指
+ e.preventDefault(); // 阻止默认缩放行为
+ }
+});
+
+// 获取搜索框输入和所有工具卡片
+const searchInput = document.getElementById('search-input');
+const toolCards = document.querySelectorAll('.tool-card');
+
+// 监听搜索框的输入事件
+searchInput.addEventListener('input', function() {
+ const searchTerm = searchInput.value.toLowerCase().trim(); // 获取搜索关键词并转换为小写
+
+ // 过滤工具卡片
+ filterCards(searchTerm);
+});
+
+// 过滤工具卡片
+function filterCards(searchTerm) {
+ const filteredCards = Array.from(toolCards).filter(card => {
+ const title = card.querySelector('.tool-name').textContent.toLowerCase();
+ const description = card.querySelector('.card-description').textContent.toLowerCase();
+ return title.includes(searchTerm) || description.includes(searchTerm);
+ });
+
+ // 更新卡片布局
+ updateCardLayout(filteredCards, searchTerm);
+}
+
+// 更新卡片布局,确保卡片顺序正确
+function updateCardLayout(filteredCards, searchTerm) {
+ const container = document.querySelector('.tools-grid');
+ container.innerHTML = ''; // 清空容器中的所有卡片
+
+ if (searchTerm === '') {
+ // 如果搜索框为空,恢复原始顺序
+ toolCards.forEach(card => container.appendChild(card));
+ } else {
+ // 搜索时按顺序添加匹配的卡片
+ filteredCards.forEach(card => container.appendChild(card));
+ }
+
+ // 确保跳转链接依然有效
+ addLinkFunctionality(filteredCards);
+}
+
+// 为每个卡片的链接添加跳转功能
+function addLinkFunctionality(cards) {
+ cards.forEach(card => {
+ const link = card.querySelector('.tool-card-link'); // 获取卡片中的链接元素
+ if (link) {
+ // 确保链接点击时会跳转(无论是旧标签还是新标签)
+ link.addEventListener('click', function(event) {
+ // 如果需要额外的功能(比如日志记录等),可以插入代码
+ // 例如:console.log('Tool clicked:', link.href);
+ // 无需手动修改 target="_blank",浏览器会根据 标签的设置自动处理
+ });
+ }
+ });
+}
+
+// 获取两个全屏按钮
+const fullscreenButton = document.getElementById('fullscreen-button');
+const sidebarFullscreenButton = document.getElementById('sidebar-fullscreen-button');
+
+// 绑定全屏切换事件
+function toggleFullscreen() {
+ if (!document.fullscreenElement) {
+ if (document.documentElement.requestFullscreen) {
+ document.documentElement.requestFullscreen();
+ } else if (document.documentElement.mozRequestFullScreen) {
+ document.documentElement.mozRequestFullScreen();
+ } else if (document.documentElement.webkitRequestFullscreen) {
+ document.documentElement.webkitRequestFullscreen();
+ } else if (document.documentElement.msRequestFullscreen) {
+ document.documentElement.msRequestFullscreen();
+ }
+ updateFullscreenButton(true);
+ } else {
+ if (document.exitFullscreen) {
+ document.exitFullscreen();
+ } else if (document.mozCancelFullScreen) {
+ document.mozCancelFullScreen();
+ } else if (document.webkitExitFullscreen) {
+ document.webkitExitFullscreen();
+ } else if (document.msExitFullscreen) {
+ document.msExitFullscreen();
+ }
+ updateFullscreenButton(false);
+ }
+}
+
+// 更新按钮文本和图标
+function updateFullscreenButton(isFullscreen) {
+ const buttons = [fullscreenButton, sidebarFullscreenButton];
+ buttons.forEach(button => {
+ if (isFullscreen) {
+ button.querySelector('span').textContent = '退出';
+ button.querySelector('.icon').innerHTML = '↵'; // 退出全屏图标
+ } else {
+ button.querySelector('span').textContent = '全屏';
+ button.querySelector('.icon').innerHTML = '⛶'; // 全屏图标
+ }
+ });
+}
+
+// 绑定点击事件
+fullscreenButton.addEventListener('click', toggleFullscreen);
+sidebarFullscreenButton.addEventListener('click', toggleFullscreen);
+
+// 页面加载完成后滚动到顶部
+window.addEventListener('load', function() {
+ setTimeout(function() {
+ window.scrollTo(0, 0); // 将页面滚动到顶部
+ }, 100); // 延迟 100ms 执行,确保页面已完全加载
+});
\ No newline at end of file
diff --git a/styles.css b/styles.css
new file mode 100644
index 0000000..bed0fd8
--- /dev/null
+++ b/styles.css
@@ -0,0 +1,422 @@
+/* 基本样式重置 */
+body, html {
+ margin: 0;
+ padding: 0;
+ font-family: Arial, sans-serif; /* 设置页面的默认字体 */
+ background-color:#f4f4f4;
+}
+
+/* 头部样式 */
+header {
+ position: fixed;
+ top: 0;
+ left: 0;
+ width: 100%;
+ background-color: #ffffff;
+ color: #fff;
+ padding: 10px;
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ z-index: 3000;
+ transition: all 1s ease; /* 为头部的尺寸变化和样式变化添加过渡效果 */
+}
+
+#search-input {
+ height: 20px;
+ width: 500px;
+ display: inline-block;
+ border: 1px solid #ccc;
+ border-radius: 20px;
+ padding: 5px 15px;
+ transition: width 0.3s ease, padding 0.3s ease, top 0.3s ease; /* 加入 top 过渡效果 */
+ outline: none;
+ background-color: #fff;
+ text-align: center;
+ margin-bottom: 20px;
+ position: fixed; /* 固定定位 */
+ top: 10px; /* 初始位置距离顶部20px */
+ left: 50%;
+ transform: translateX(-50%); /* 居中显示 */
+ z-index: 1000; /* 确保在顶部 */
+}
+
+/* 鼠标悬停时搜索框展开 */
+#search-input:hover,
+#search-input:focus {
+ width: 600px; /* 展开宽度 */
+ padding: 5px 20px; /* 调整内边距 */
+ box-shadow: 0 0 5px rgba(0, 0, 0, 0.2); /* 添加阴影效果 */
+}
+
+
+/* 按钮的基础样式 */
+header .toggle-menu {
+ display: inline-block;
+ font-size: 24px;
+ background: none;
+ border: none;
+ color: rgb(235, 10, 10);
+ cursor: pointer;
+ margin-right: 20px; /* 设置右边距 */
+ transition: transform 0.3s ease-in-out; /* 添加平滑过渡效果 */
+}
+
+/* 悬停效果,按钮背景颜色变化 */
+header .toggle-menu:hover {
+ background-color: rgba(235, 10, 10, 0.1); /* 增加轻微的背景色变化 */
+}
+
+/* 头部全屏按钮样式(仅大屏幕显示) */
+#fullscreen-button {
+ position: absolute;
+ right: 16px;
+ top: 0px;
+ background: none;
+ border: none;
+ cursor: pointer;
+ font-size: 32px;
+ display: flex;
+ align-items: center;
+ transition: top 0.3s ease,transform 0.3s ease-in-out, padding 0.3s ease-in-out; /* 平滑放大动画 */
+ transform-origin: center center; /* 确保放大时的中心不变 */
+}
+
+#fullscreen-button:hover {
+ transform: scale(1.20); /* 悬停时上下左右均匀放大 5% */
+}
+
+/* 侧边栏 */
+.sidebar {
+ position: fixed;
+ top: -30px;
+ left: 0;
+ width: 250px;
+ bottom: 24px;
+ background-color: #f4f4f4;
+ color: rgb(100, 99, 99); /* logo颜色 */
+ display: flex;
+ flex-direction: column;
+ align-items: center; /* 水平居中 */
+ padding: 20px;
+ transition: transform 0.3s ease-in-out;
+ z-index: 2000;
+}
+
+/* 使用 @font-face 引用本地字体 */
+@font-face {
+ font-family: 'Pacifico'; /* 字体名称 */
+ src: url('font/Pacifico.ttf') format('truetype'); /* 设置 .ttf 格式 */
+ font-weight: normal;
+ font-style: normal;
+}
+
+.logo {
+ font-family: 'Pacifico', cursive; /* 使用本地字体 Pacifico */
+ margin: 0;
+ padding-top: 48px;
+ text-align: center; /* 确保整个 logo 居中 */
+ display: flex;
+ flex-direction: column; /* 将 part1 和 part2 垂直排列 */
+ align-items: center; /* 确保每个部分居中 */
+}
+
+.logo .part1 {
+ font-size: 50px; /* "ream" 字体较大 */
+}
+
+.logo .part2 {
+ font-size: 40px; /* ".life" 字体较小 */
+}
+
+/* 侧边栏链接的基础样式 */
+.sidebar-link {
+ position: relative;
+ font-size: 22px;
+ font-weight: bold;
+ margin-top: 48px;
+ color: rgb(117, 115, 115);
+ text-decoration: none; /* 去掉默认的下划线 */
+ display: inline-block;
+ padding: 10px 20px;
+ background-color: #f4f4f4;
+ transition: all 0.3s ease; /* 添加平滑过渡效果 */
+}
+
+/* 侧边栏链接内容的容器 */
+.sidebar-link .link-content {
+ display: flex;
+ background-color: #f4f4f4;
+ align-items: center; /* 确保文字和图标垂直居中 */
+ transition: transform 0.3s ease; /* 添加平滑过渡 */
+}
+
+/* 悬停时图标和文字一起上浮 */
+.sidebar-link:hover .link-content {
+ transform: translateY(-3px); /* 向上浮起5px */
+}
+
+/* 图标样式 */
+.sidebar-link .icon {
+ margin-right: 10px; /* 给图标和文字之间留点空隙 */
+}
+
+/* 悬停时改变链接的颜色 */
+.sidebar-link:hover {
+ color: #000;
+}
+
+/* 按钮文本和图标的状态样式 */
+.sidebar-link.fullscreen .icon {
+ transform: rotate(90deg); /* 图标旋转 */
+}
+
+/* 退出全屏时的样式 */
+.sidebar-link.fullscreen span {
+ content: "退出全屏"; /* 修改文本为"退出全屏" */
+}
+
+
+/* 禁用页面滚动样式 */
+body.no-scroll {
+ overflow: hidden; /* 禁止页面滚动 */
+}
+
+/* 主内容区 */
+.main-content {
+ margin-left: 270px;
+ margin-right: 20px;
+ margin-top: 14px; /* 增加主内容区的上边距 */
+ padding: 20px;
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
+ z-index: 1; /* 确保内容在侧边栏下方 */
+ position: relative; /* 确保相对定位 */
+}
+
+.sidebar {
+ flex: 1 1 250px; /* 允许侧边栏在可用空间内缩放 */
+}
+
+.content {
+ flex: 3 1 600px; /* 允许内容区域在可用空间内缩放 */
+}
+
+/* 为整个工具卡片添加链接样式 */
+.tool-card-link {
+ text-decoration: none; /* 去掉链接的下划线 */
+}
+/* 保证工具卡片正常排列 */
+.tools-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
+ gap: 20px;
+ padding: 20px;
+}
+
+/* 保证工具卡片的顺序 */
+.tool-card {
+ display: flex;
+ flex-direction: column; /* 使 logo 在上,名称在下 */
+ align-items: flex-start; /* 左对齐 */
+ background: white;
+ border-radius: 8px;
+ box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
+ padding: 20px;
+ text-align: left; /* 左对齐 */
+ min-height: 180px;
+ transition: transform 0.5s ease, box-shadow 0.5s ease; /* 工具卡片动画时间设置为 0.5s */
+}
+
+/* 工具卡片动画完成状态 */
+.tool-card.animated {
+ opacity: 1;
+ transform: translateY(0); /* 恢复到正常位置 */
+}
+
+/* 工具卡片悬停效果 */
+.tool-card:hover {
+ transform: scale(1.03);
+ box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
+}
+
+/* 工具卡片logo样式 */
+.tool-logo {
+ margin-left: 30px;
+ margin-top: 10px;
+ width: 50px; /* 设置logo的宽度 */
+ height: 50px;
+ margin-bottom: 10px; /* 给logo和名称之间留出间距 */
+ border-radius: 8px; /* 设置圆角矩形 */
+ object-fit: cover; /* 保证图片不会被拉伸或变形 */
+}
+
+/* 工具名称的样式 */
+.tool-name {
+ margin-left: 30px;
+ margin-top: 10px;
+ font-size: 20px;
+ font-weight: bold;
+ color: #333;
+ text-decoration: none;
+ position: relative; /* 使下划线定位相对 */
+ display: block; /* 确保工具名称独占一行 */
+ text-align: left; /* 左对齐 */
+}
+
+/* 工具名称的下划线效果 */
+.tool-name::after {
+ content: "";
+ position: absolute;
+ bottom: -5px;
+ left: 0;
+ width: 0;
+ height: 2px;
+ background-color: black;
+ transition: width 0.3s ease;
+}
+
+.tool-name:hover::after {
+ width: 100%; /* 让下划线横跨整个文字 */
+}
+
+/* 分类标签样式 */
+.tool-category {
+ display: inline-block; /* 使标签处于同一行 */
+ padding: 4px 16px; /* 胶囊形状的内边距,横向较宽 */
+ background-color: #fc8f8f; /* 背景颜色 */
+ color: #ffffff; /* 文字颜色 */
+ font-size: 10px; /* 字体大小 */
+ font-weight: bold; /* 加粗字体 */
+ border-radius: 50px; /* 设置圆角,形成胶囊形状 */
+ margin-left: 30px;
+ margin-top: 10px; /* 给标签和描述之间留出间距 */
+}
+
+/* 工具描述样式 */
+.card-description {
+ font-size: 14px;
+ color: #777;
+ margin-left: 30px;
+ margin-top: 10px; /* 给描述添加上边距 */
+}
+
+/* 悬停效果 */
+.tool-card:hover {
+ transform: scale(1.03);
+ box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
+}
+
+/* 页脚样式 - 默认 (电脑设备) */
+footer {
+ background-color: rgba(51, 51, 51, 0.5); /* 半透明背景 */
+ color: white;
+ display: flex; /* 使用 flex 布局 */
+ justify-content: center; /* 水平居中 */
+ align-items: center; /* 垂直居中 */
+ padding: 0px;
+ position: fixed;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ font-size: 14px;
+ max-height: 30px;
+ z-index: 2000; /* 提升侧边栏的层级 */
+}
+
+/* 响应式设计 */
+@media (max-width: 768px) {
+ #fullscreen-button {
+ display: none; /* 小屏幕隐藏头部全屏按钮 */
+ }
+
+ #sidebar-fullscreen-button {
+ display: flex; /* 小屏幕显示侧边栏全屏按钮 */
+ }
+
+ #search-input {
+ width: 50%; /* 设置宽度为屏幕的50% */
+ padding: 5px 15px;
+ top: 10px;
+ left: 50%; /* 使搜索框居中 */
+ }
+
+ #search-input:hover,
+ #search-input:focus {
+ width: 60%; /* 展开宽度 */
+ padding: 5px 20px; /* 调整内边距 */
+ box-shadow: 0 0 5px rgba(0, 0, 0, 0.2); /* 添加阴影效果 */
+ }
+
+ /* 小屏幕时侧边栏 */
+ .sidebar {
+ width: 80%; /* 设置侧边栏宽度为60% */
+ bottom: 0;
+ transform: translateX(-100%); /* 默认隐藏侧边栏 */
+ }
+
+ .sidebar.open {
+ transform: translateX(0);
+ bottom: 0;
+ width: 80%; /* 确保侧边栏在打开时宽度为60% */
+ }
+
+ /* 小屏幕时主内容区 */
+ .main-content {
+ margin-left: 0px; /* 小屏幕时移除左边距 */
+ margin-right: 0px; /* 小屏幕时右边距减小 */
+ margin-top: 60px; /* 小屏幕时稍微减小上边距 */
+ }
+
+ /* 小屏幕时头部 */
+ header {
+ height: 40px; /* 设置头部高度为50px */
+ justify-content: space-between; /* 保持头部内容在两端 */
+ align-items: center; /* 垂直居中内容 */
+ }
+ /* 小屏幕时菜单按钮 */
+ header .toggle-menu {
+ display: block; /* 在小屏幕时显示菜单按钮 */
+ font-size: 24px;
+ background: none;
+ border: none;
+ color: rgb(235, 10, 10);
+ cursor: pointer;
+ position: absolute;
+ top: 10px; /* 距离顶部20px */
+ right: 14px; /* 距离右侧20px */
+ transition: transform 0.3s ease-in-out; /* 添加平滑过渡效果 */
+ }
+
+ /* 悬停效果,按钮背景颜色变化 */
+ header .toggle-menu:hover {
+ background-color: rgba(235, 10, 10, 0.1); /* 增加轻微的背景色变化 */
+ }
+}
+
+@media (min-width: 768px) {
+ header {
+ background: none; /* 去掉头部背景色 */
+ box-shadow: none; /* 去掉头部阴影 */
+ height: auto; /* 自动高度适应搜索框 */
+ padding: 0; /* 去掉多余的内边距 */
+ top: 10px;
+ }
+
+ #fullscreen-button {
+ display: flex; /* 小屏幕隐藏头部全屏按钮 */
+ }
+
+ #sidebar-fullscreen-button {
+ display: none; /* 小屏幕显示侧边栏全屏按钮 */
+ }
+
+ #search-input {
+ margin: 0 auto; /* 搜索框居中显示 */
+ }
+
+ header .toggle-menu {
+ display: none; /* 在小屏幕时显示菜单按钮 */
+ }
+}
\ No newline at end of file