js+css实现本地多张图片各种形状排列拼图代码

代码语言:html

所属分类:其他

代码描述:js+css实现本地多张图片各种形状排列拼图代码

代码标签: js css 本地 多张 图片 各种 形状 排列 拼图 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>形状拼贴工坊 · Shape Mosaic Studio</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700;900&family=ZCOOL+KuaiLe&display=swap" rel="stylesheet">
<style>
:root {
    --bg: #f0f2f5;
    --panel: #ffffff;
    --panel-hover: #f8f9fa;
    --border: #e9ecef;
    --border-strong: #dee2e6;
    --fg: #212529;
    --fg-2: #495057;
    --muted: #868e96;
    --accent: #ff5e7a;
    --accent-2: #ff8c42;
    --accent-3: #20c997;
    --danger: #fa5252;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; }

body {
    font-family: 'Noto Sans SC', sans-serif;
    background: var(--bg);
    color: var(--fg);
    font-size: 14px;
}

.app {
    display: grid;
    grid-template-columns: 380px 1fr;
    height: 100vh;
}

.sidebar {
    background: var(--panel);
    border-right: 1px solid var(--border);
    padding: 24px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.brand {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.brand-title {
    font-family: 'ZCOOL KuaiLe', cursive;
    font-size: 30px;
    font-weight: 400;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.1;
    margin-bottom: 6px;
}

.brand-sub {
    font-size: 10px;
    color: var(--muted);
    letter-spacing: 2.5px;
    text-transform: uppercase;
    font-weight: 700;
}

.section { margin-bottom: 24px; }

.section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--fg-2);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::before {
    content: '';
    width: 4px;
    height: 14px;
    background: linear-gradient(to bottom, var(--accent), var(--accent-2));
    border-radius: 2px;
}

.upload-area {
    position: relative;
    border: 2px dashed var(--border-strong);
    border-radius: 12px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    background: var(--panel-hover);
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--accent);
    background: rgba(255, 94, 122, 0.04);
}

.upload-icon {
    width: 44px;
    height: 44px;
    margin: 0 auto 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 6px 16px rgba(255, 94, 122, 0.3);
}

.upload-text {
    font-size: 14px;
    color: var(--fg);
    margin-bottom: 4px;
    font-weight: 600;
}

.upload-hint {
    font-size: 12px;
    color: var(--muted);
}

.upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.image-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 14px;
    max-height: 100px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.image-list::-webkit-scrollbar { width: 4px; }
.image-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

.image-thumb {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.2s;
    flex-shrink: 0;
    background: var(--bg);
}

.image-thumb:hover { transform: scale(1.1); }

.image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-thumb .remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: white;
    opacity: 0;
    transition: opacity 0.2s;
    line-height: 1;
}

.image-thumb:hover .remove { opacity: 1; }

.image-count {
    margin-top: 12px;
    font-size: 12px;
    color: var(--muted);
}

.image-count strong {
    color: var(--accent);
    font-weight: 800;
    font-size: 14px;
}

.shape-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.shape-btn {
    aspect-ratio: 1;
    background: var(--panel-hover);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items:.........完整代码请登录后点击上方下载按钮下载查看

网友评论0