ibook / style.css
zhangl
Refactor index.html, README.md, and style.css for interactive English learning app. Updated HTML structure, added navigation and control features, enhanced styling, and improved documentation in README.
c7e7ea8
Raw
History Blame Contribute Delete
18.2 kB
/* 全局样式重置和基础设置 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
--primary-color: #2563eb;
--primary-hover: #1d4ed8;
--secondary-color: #64748b;
--success-color: #059669;
--warning-color: #d97706;
--error-color: #dc2626;
--bg-primary: #ffffff;
--bg-secondary: #f8fafc;
--bg-tertiary: #e2e8f0;
--text-primary: #1e293b;
--text-secondary: #475569;
--text-muted: #64748b;
--border-color: #e2e8f0;
--shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
--shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
--border-radius: 8px;
--border-radius-lg: 12px;
--border-radius-xl: 16px;
--font-size-sm: 0.875rem;
--font-size-base: 1rem;
--font-size-lg: 1.125rem;
--font-size-xl: 1.25rem;
--font-size-2xl: 1.5rem;
--z-index-dropdown: 1000;
--z-index-overlay: 2000;
--z-index-modal: 3000;
--z-index-toast: 4000;
}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', '微软雅黑', Roboto, sans-serif;
background-color: var(--bg-secondary);
color: var(--text-primary);
line-height: 1.6;
}
.app-container {
min-height: 100vh;
display: flex;
flex-direction: column;
}
/* 顶部导航栏 */
.header {
background: var(--bg-primary);
border-bottom: 1px solid var(--border-color);
box-shadow: var(--shadow-sm);
position: sticky;
top: 0;
z-index: var(--z-index-dropdown);
}
.header-content {
max-width: 1200px;
margin: 0 auto;
padding: 1rem 1.5rem;
display: flex;
justify-content: space-between;
align-items: center;
}
.app-title {
font-size: var(--font-size-xl);
font-weight: 600;
color: var(--primary-color);
display: flex;
align-items: center;
gap: 0.75rem;
}
.app-title i {
font-size: var(--font-size-2xl);
}
.controls {
display: flex;
gap: 0.75rem;
}
.control-btn {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.5rem 1rem;
background: var(--bg-secondary);
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
color: var(--text-secondary);
font-size: var(--font-size-sm);
cursor: pointer;
transition: all 0.2s ease;
}
.control-btn:hover {
background: var(--primary-color);
color: white;
border-color: var(--primary-color);
}
.control-btn.active {
background: var(--primary-color);
color: white;
border-color: var(--primary-color);
}
/* 主要内容区域 */
.main-content {
flex: 1;
max-width: 1200px;
margin: 0 auto;
width: 100%;
padding: 1.5rem;
}
/* 页面导航 */
.page-navigation {
display: flex;
align-items: center;
justify-content: center;
gap: 1rem;
margin-bottom: 1.5rem;
padding: 1rem;
background: var(--bg-primary);
border-radius: var(--border-radius-lg);
box-shadow: var(--shadow-sm);
}
.nav-btn {
width: 2.5rem;
height: 2.5rem;
border: 1px solid var(--border-color);
background: var(--bg-primary);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: all 0.2s ease;
color: var(--text-secondary);
}
.nav-btn:hover {
background: var(--primary-color);
color: white;
border-color: var(--primary-color);
}
.nav-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.nav-btn:disabled:hover {
background: var(--bg-primary);
color: var(--text-secondary);
border-color: var(--border-color);
}
.page-info {
font-size: var(--font-size-lg);
font-weight: 500;
color: var(--text-primary);
min-width: 4rem;
text-align: center;
}
.progress-bar {
flex: 1;
max-width: 200px;
height: 4px;
background: var(--bg-tertiary);
border-radius: 2px;
overflow: hidden;
margin-left: 1rem;
}
.progress-fill {
height: 100%;
background: var(--primary-color);
border-radius: 2px;
transition: width 0.3s ease;
}
/* 页面容器 */
.page-container {
background: var(--bg-primary);
border-radius: var(--border-radius-xl);
box-shadow: var(--shadow-lg);
overflow: hidden;
min-height: 500px;
display: flex;
align-items: center;
justify-content: center;
}
.loading {
text-align: center;
color: var(--text-muted);
}
.loading i {
font-size: 2rem;
margin-bottom: 1rem;
color: var(--primary-color);
}
.page-content {
width: 100%;
height: 100%;
}
.page-image-container {
position: relative;
width: 100%;
height: 100%;
min-height: 500px;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
}
.page-image {
max-width: 100%;
max-height: 80vh;
height: auto;
border-radius: var(--border-radius);
box-shadow: var(--shadow-md);
display: block;
}
/* 文本覆盖层 */
.text-overlays {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
}
.text-piece {
position: absolute;
background: transparent;
border: 1px solid transparent;
border-radius: 4px;
cursor: pointer;
pointer-events: all;
transition: all 0.3s ease;
padding: 0;
}
.text-piece:hover {
background: rgba(37, 99, 235, 0.08);
border-color: rgba(37, 99, 235, 0.8);
border-width: 2px;
box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.2);
}
.text-piece.active {
background: rgba(37, 99, 235, 0.12);
border-color: var(--primary-color);
border-width: 2px;
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.4);
animation: activeFlash 1s ease-in-out;
}
.text-piece.playing {
border-color: var(--success-color);
box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.4);
animation: playingPulse 2s ease-in-out infinite;
}
/* 交互模式下显示所有区域的轮廓 */
.show-interactive-areas .text-piece {
background: rgba(37, 99, 235, 0.05);
border-color: rgba(37, 99, 235, 0.3);
border-width: 1px;
}
.show-interactive-areas .text-piece:hover {
background: rgba(37, 99, 235, 0.1);
border-color: var(--primary-color);
border-width: 2px;
}
.piece-text {
font-size: var(--font-size-sm);
font-weight: 500;
color: var(--text-primary);
text-shadow: 0 1px 2px rgba(255, 255, 255, 1);
line-height: 1.3;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', '微软雅黑', sans-serif;
opacity: 0;
pointer-events: none;
display: none;
}
.piece-translation {
font-size: 0.75rem;
color: var(--text-secondary);
margin-top: 0.125rem;
text-shadow: 0 1px 2px rgba(255, 255, 255, 1);
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', '微软雅黑', sans-serif;
opacity: 0;
pointer-events: none;
display: none;
}
/* 交互模式下显示文本(仅用于调试) */
.show-interactive-areas .piece-text {
opacity: 0.6;
display: block;
background: rgba(255, 255, 255, 0.9);
padding: 0.125rem 0.25rem;
border-radius: 2px;
font-size: 0.7rem;
}
.show-interactive-areas .piece-translation {
opacity: 0.5;
display: block;
background: rgba(255, 255, 255, 0.8);
padding: 0.125rem 0.25rem;
border-radius: 2px;
font-size: 0.6rem;
}
/* 底部控制面板 */
.bottom-panel {
margin-top: 1.5rem;
}
.audio-player {
background: var(--bg-primary);
border-radius: var(--border-radius-lg);
padding: 1rem;
box-shadow: var(--shadow-md);
}
.audio-info {
display: flex;
flex-direction: column;
gap: 1rem;
}
.audio-text {
font-size: var(--font-size-lg);
font-weight: 500;
color: var(--text-primary);
text-align: center;
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', '微软雅黑', sans-serif;
}
.audio-controls {
display: flex;
align-items: center;
gap: 1rem;
}
.audio-btn {
width: 2.5rem;
height: 2.5rem;
border: none;
background: var(--primary-color);
color: white;
border-radius: 50%;
cursor: pointer;
transition: all 0.2s ease;
display: flex;
align-items: center;
justify-content: center;
}
.audio-btn:hover {
background: var(--primary-hover);
transform: scale(1.05);
}
.audio-progress {
flex: 1;
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.audio-timeline {
height: 4px;
background: var(--bg-tertiary);
border-radius: 2px;
cursor: pointer;
position: relative;
}
.audio-progress-bar {
height: 100%;
background: var(--primary-color);
border-radius: 2px;
transition: width 0.1s ease;
}
.audio-time {
display: flex;
justify-content: space-between;
font-size: var(--font-size-sm);
color: var(--text-muted);
}
/* 搜索面板 */
.search-panel {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
z-index: var(--z-index-modal);
display: flex;
align-items: center;
justify-content: center;
padding: 1rem;
}
.search-content {
background: var(--bg-primary);
border-radius: var(--border-radius-xl);
box-shadow: var(--shadow-lg);
width: 100%;
max-width: 600px;
max-height: 80vh;
overflow: hidden;
}
.search-header {
padding: 1.5rem;
border-bottom: 1px solid var(--border-color);
display: flex;
justify-content: space-between;
align-items: center;
}
.search-body {
padding: 1.5rem;
max-height: 60vh;
overflow-y: auto;
}
.search-input-container {
display: flex;
gap: 0.5rem;
margin-bottom: 1.5rem;
}
.search-input-container input {
flex: 1;
padding: 0.75rem 1rem;
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
font-size: var(--font-size-base);
outline: none;
transition: border-color 0.2s ease;
}
.search-input-container input:focus {
border-color: var(--primary-color);
}
.search-btn {
padding: 0.75rem 1rem;
background: var(--primary-color);
color: white;
border: none;
border-radius: var(--border-radius);
cursor: pointer;
transition: background-color 0.2s ease;
}
.search-btn:hover {
background: var(--primary-hover);
}
.search-results {
min-height: 200px;
}
.search-empty {
text-align: center;
color: var(--text-muted);
padding: 2rem;
font-style: italic;
}
.search-result-item {
padding: 1rem;
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
margin-bottom: 0.75rem;
cursor: pointer;
transition: all 0.2s ease;
}
.search-result-item:hover {
border-color: var(--primary-color);
background: var(--bg-secondary);
}
.search-result-page {
font-size: var(--font-size-sm);
color: var(--text-muted);
margin-bottom: 0.5rem;
}
.search-result-text {
font-weight: 500;
margin-bottom: 0.25rem;
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', '微软雅黑', sans-serif;
}
.search-result-translation {
color: var(--text-secondary);
font-size: var(--font-size-sm);
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', '微软雅黑', sans-serif;
}
.search-highlight {
background: yellow;
padding: 0.125rem 0.25rem;
border-radius: 2px;
}
/* 书签面板 */
.bookmark-panel {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
z-index: var(--z-index-modal);
display: flex;
align-items: center;
justify-content: center;
padding: 1rem;
}
.bookmark-content {
background: var(--bg-primary);
border-radius: var(--border-radius-xl);
box-shadow: var(--shadow-lg);
width: 100%;
max-width: 500px;
max-height: 80vh;
overflow: hidden;
}
.bookmark-header {
padding: 1.5rem;
border-bottom: 1px solid var(--border-color);
display: flex;
justify-content: space-between;
align-items: center;
}
.bookmark-body {
padding: 1.5rem;
max-height: 60vh;
overflow-y: auto;
}
.bookmark-empty {
text-align: center;
color: var(--text-muted);
padding: 2rem;
font-style: italic;
}
.bookmark-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem;
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
margin-bottom: 0.75rem;
cursor: pointer;
transition: all 0.2s ease;
}
.bookmark-item:hover {
border-color: var(--primary-color);
background: var(--bg-secondary);
}
.bookmark-info {
flex: 1;
}
.bookmark-page {
font-weight: 500;
color: var(--text-primary);
margin-bottom: 0.25rem;
}
.bookmark-time {
font-size: var(--font-size-sm);
color: var(--text-muted);
}
.bookmark-actions {
display: flex;
gap: 0.5rem;
}
.bookmark-delete {
width: 1.5rem;
height: 1.5rem;
border: none;
background: var(--error-color);
color: white;
border-radius: 50%;
cursor: pointer;
transition: all 0.2s ease;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.75rem;
}
.bookmark-delete:hover {
transform: scale(1.1);
}
/* 设置面板 */
.settings-panel {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
z-index: var(--z-index-modal);
display: flex;
align-items: center;
justify-content: center;
padding: 1rem;
}
.settings-content {
background: var(--bg-primary);
border-radius: var(--border-radius-xl);
box-shadow: var(--shadow-lg);
width: 100%;
max-width: 400px;
max-height: 80vh;
overflow-y: auto;
}
.settings-header {
padding: 1.5rem;
border-bottom: 1px solid var(--border-color);
display: flex;
justify-content: space-between;
align-items: center;
}
.settings-header h3 {
font-size: var(--font-size-xl);
font-weight: 600;
color: var(--text-primary);
}
.close-btn {
width: 2rem;
height: 2rem;
border: none;
background: none;
color: var(--text-muted);
cursor: pointer;
border-radius: 4px;
transition: all 0.2s ease;
}
.close-btn:hover {
background: var(--bg-secondary);
color: var(--text-primary);
}
.settings-body {
padding: 1.5rem;
}
.setting-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem 0;
border-bottom: 1px solid var(--border-color);
}
.setting-item:last-child {
border-bottom: none;
}
.setting-item label {
font-weight: 500;
color: var(--text-primary);
}
.setting-item input[type="checkbox"] {
width: 1rem;
height: 1rem;
accent-color: var(--primary-color);
}
.setting-item select {
padding: 0.25rem 0.5rem;
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
background: var(--bg-primary);
color: var(--text-primary);
}
/* 消息提示 */
.toast {
position: fixed;
bottom: 2rem;
left: 50%;
transform: translateX(-50%);
background: var(--text-primary);
color: white;
padding: 0.75rem 1.5rem;
border-radius: var(--border-radius);
box-shadow: var(--shadow-lg);
z-index: var(--z-index-toast);
opacity: 0;
visibility: hidden;
transition: all 0.3s ease;
}
.toast.show {
opacity: 1;
visibility: visible;
}
.toast.success {
background: var(--success-color);
}
.toast.warning {
background: var(--warning-color);
}
.toast.error {
background: var(--error-color);
}
/* 响应式设计 */
@media (max-width: 768px) {
.header-content {
padding: 1rem;
flex-direction: column;
gap: 1rem;
}
.controls {
width: 100%;
justify-content: center;
}
.main-content {
padding: 1rem;
}
.page-navigation {
flex-wrap: wrap;
gap: 0.75rem;
}
.progress-bar {
width: 100%;
margin-left: 0;
margin-top: 0.5rem;
}
.audio-controls {
flex-direction: column;
gap: 0.75rem;
}
.control-btn span {
display: none;
}
.text-piece {
min-width: 2rem;
min-height: 1.5rem;
}
.piece-text {
font-size: 0.75rem;
}
.piece-translation {
font-size: 0.625rem;
}
}
@media (max-width: 480px) {
.app-title {
font-size: var(--font-size-lg);
}
.page-info {
font-size: var(--font-size-base);
}
.settings-content {
margin: 0.5rem;
}
}
/* 动画效果 */
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(1rem);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes pulse {
0%, 100% {
transform: scale(1);
}
50% {
transform: scale(1.05);
}
}
@keyframes activeFlash {
0% {
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.4);
}
50% {
box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.6);
}
100% {
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.4);
}
}
@keyframes playingPulse {
0% {
box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.4);
}
50% {
box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.6);
}
100% {
box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.4);
}
}
.page-content {
animation: fadeIn 0.3s ease;
}
.text-piece.playing {
animation: pulse 1s ease-in-out infinite;
}
/* 滚动条样式 */
::-webkit-scrollbar {
width: 6px;
height: 6px;
}
::-webkit-scrollbar-track {
background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
background: var(--border-color);
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--text-muted);
}