抖音对话生成器在线制作,包括快手也可以适配下即可,评论聊天html+js+css

其实是通过js+html+css动态生成对话内容的工具,前段设置对话内容头像时间这些信息,js就能自动把信息更新到前段页面里面。

  • HTML:用于搭建页面结构。

  • CSS:用于美化页面样式。

  • JavaScript:实现核心逻辑,包括对话生成、随机选择、复制功能等。

核心框架代码部分:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>抖音对话生成器</title>
    <style>
        /* CSS 样式 */
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f9;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        .container {
            background-color: #fff;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            width: 400px;
            text-align: center;
        }

        h1 {
            font-size: 24px;
            margin-bottom: 20px;
        }

        .input-group, .output-group {
            margin-bottom: 15px;
        }

        label {
            display: block;
            font-weight: bold;
            margin-bottom: 5px;
        }

        textarea {
            width: 100%;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
            font-size: 14px;
            resize: none;
        }

        button {
            padding: 10px 20px;
            margin: 5px;
            border: none;
            border-radius: 5px;
            background-color: #007bff;
            color: #fff;
            font-size: 14px;
            cursor: pointer;
            transition: background-color 0.3s;
        }

        button:hover {
            background-color: #0056b3;
        }

        #output {
            background-color: #f9f9f9;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>抖音对话生成器</h1>
        <div class="input-group">
            <label for="user1">用户1名称:</label>
            <input type="text" id="user1" placeholder="例如:小明" value="小明">
        </div>
        <div class="input-group">
            <label for="user2">用户2名称:</label>
            <input type="text" id="user2" placeholder="例如:小红" value="小红">
        </div>
        <div class="input-group">
            <button id="generate-btn">生成对话</button>
            <button id="copy-btn">复制对话</button>
        </div>
        <div class="output-group">
            <label for="output">生成的对话:</label>
            <textarea id="output" readonly></textarea>
        </div>
    </div>

    <script>
        // JavaScript 逻辑
        document.addEventListener('DOMContentLoaded', () => {
            const user1Input = document.getElementById('user1');
            const user2Input = document.getElementById('user2');
            const generateBtn = document.getElementById('generate-btn');
            const copyBtn = document.getElementById('copy-btn');
            const outputArea = document.getElementById('output');

            // 预设的对话库
            const dialogues = [
                "{用户1}:这个视频太搞笑了!\n{用户2}:哈哈哈,我也笑疯了!",
                "{用户1}:你觉得这个视频怎么样?\n{用户2}:我觉得很棒,很有创意!",
                "{用户1}:这个背景音乐真好听!\n{用户2}:对啊,我已经单曲循环了!",
                "{用户1}:你觉得博主会回复我们吗?\n{用户2}:说不定哦,博主很宠粉的!",
                "{用户1}:这个视频让我想起了小时候。\n{用户2}:我也是,满满的回忆!"
            ];

            // 生成对话
            generateBtn.addEventListener('click', () => {
                const user1 = user1Input.value || '用户1';
                const user2 = user2Input.value || '用户2';
                const dialogueTemplate = dialogues[Math.floor(Math.random() * dialogues.length)];

                const dialogue = dialogueTemplate
                    .replace(/{用户1}/g, user1)
                    .replace(/{用户2}/g, user2);

                outputArea.value = dialogue;
            });

            // 复制对话
            copyBtn.addEventListener('click', () => {
                outputArea.select();
                document.execCommand('copy');
                alert('对话已复制到剪贴板!');
            });
        });
    </script>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值