css+js实现支持选择和拖拽的大气文件上传代码

代码语言:html

所属分类:上传

代码描述:css+js实现支持选择和拖拽的大气文件上传代码

代码标签: css js 支持 选择 拖拽 大气 文件 上传 代码

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

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">



    <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=Work+Sans&display=swap" rel="stylesheet">
<style>
    * {
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}

:root {
    --primary: #8800ff;
    --primary-hover: #6c00ca;
    --bg: #111315;
    --secondary: #262626;
    --secondary-hover: #383838;
    --dropzone-bg: #1A1C1E;
    --gray: #D3D3D3;
    --border: #333333;
    --dropzone-border: #FFF;
    --headline: #FFF;
    --text: #FFF;
    --primary-text: #F2F7FE;
    --dropzone-over: var(--secondary);
}

body {
    font-family: 'Work Sans', sans-serif;
    background: var(--bg);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 1rem;
    color: var(--text);
}

*::selection {
    background: var(--primary);
    color: var(--btn-text);
}

.dropzone-box {
    border-radius: 1rem;
    padding: 2rem;
    display: flex;
    justify-content: center;
    flex-direction: column;
    max-width: 36rem;
    border: 1px solid var(--border);
    width: 100%;
    background: var(--dropzone-bg);
}

.dropzone-box h2 {
    font-size: 1.4rem;
    margin-bottom: 0.6rem;
    color: var(--headline);
}

.dropzone-box p {
    font-size: 1.15rem;
    color: var(--gray);
}

.dropzone-area {
    padding: 1rem;
    position: relative;
    margin-top: 1.5rem;
    min-height: 16rem;
    display: flex;
    text-align: center;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    border: 2px dashed var(--dropzone-border);
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.dropzone-area .file-info {
    font-size: 1.1rem;
}

.dropzone-area [type="file"] {
    cursor: pointer;
    position: absolute;
    opacity: 0;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

.dropzone-area .file-upload-icon svg {
    height: 6rem;
    max-width: 6rem;
    width: 100%;
    margin-bottom: 0.5rem;
    stroke: var(--headline);
}

.dropzone-area:hover {
    background: var(--dropzone-over);
}

.dropzone--over {
    border: 2px solid var(--primary);
    background: var(--dropzone-over);
}

.dropzone-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.dropzone-actions button {
    flex-grow: 1;
    min-height: 3rem;
    font-size: 1.2rem;
    border: none;
    transition: background 0.3s ease;
}


.dropzone-actions button[type='reset'] {
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--text);
    background: var(--secondary);
    cursor: pointer;
    border: 1px solid var(--border);
}

.dropzone-actions button[type='reset']:hover {
    background: var(--secondary-hover);
}

.dropzone-actions button[type='submit'] {
    background: var(--primary);
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--primary-text);
    border: none;
    cursor: pointer;
}

.dropzone-actions button[type='submit']:hover {
    back.........完整代码请登录后点击上方下载按钮下载查看

网友评论0