DEV Community

张小云
张小云

Posted on

A HTML with CSS, CHATROOM template.

Screen Shot

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Chatroom</title>
    <style>
        /* General styles */
        body {
            font-family: 'Roboto', sans-serif;
            margin: 20;
            padding: 0;
            border-radius: 20px;
            display: flex;
            height: 100vh;
            background: linear-gradient(135deg, #e3f2fd, #ffffff);
        }

        /* Sidebar (Contact List) */
        .sidebar {
            width: 25%;
            background-color: #ffffff;
            box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
            display: flex;
            flex-direction: column;
        }

        .sidebar-header {
            padding: 15px;
            font-size: 18px;
            font-weight: bold;
            border-bottom: 1px solid #e0e0e0;
            background-color: #ffffff;
            color: #4a4a4a;
        }

        .contact-list {
            flex: 1;
            overflow-y: auto;
            background: #ffffff;
        }

        .contact-item {
            padding: 15px;
            display: flex;
            align-items: center;
            cursor: pointer;
            border-bottom: 1px solid #eeeeee;
            transition: background-color 0.3s, box-shadow 0.3s;
        }

        .contact-item:hover {
            background-color: #bbdefb;
            box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.1);
        }

        .contact-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background-color: #64b5f6;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #ffffff;
            font-weight: bold;
            margin-right: 15px;
        }

        .contact-name {
            font-size: 16px;
            color: #4a4a4a;
        }

        /* Chat Area */
        .chat-area {
            flex: 1;
            display: flex;
            flex-direction: column;
            background: linear-gradient(135deg, #ffffff, #e3f2fd);
        }

        .chat-header {
            padding: 15px;
            font-size: 18px;
            font-weight: bold;
            border-bottom: 1px solid #e0e0e0;
            background-color: #ffffff;
            color: #4a4a4a;
        }

        .messages {
            flex: 1;
            padding: 15px;
            overflow-y: auto;
        }

        .message {
            margin-bottom: 15px;
            display: flex;
            align-items: flex-start;
        }

        .message.received {
            flex-direction: row;
        }

        .message.sent {
            flex-direction: row-reverse;
        }

        .message .avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background-color: #64b5f6;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #ffffff;
            font-weight: bold;
            margin: 0 10px;
        }

        .message-content {
            max-width: 70%;
            padding: 10px 15px;
            border-radius: 20px;
            position: relative;
            font-size: 14px;
            line-height: 1.5;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            transition: transform 0.2s;
        }

        .message-content:hover {
            transform: scale(1.02);
        }

        .message.received .message-content {
            background-color: #ffffff;
            border: 1px solid #e0e0e0;
        }

        .message.sent .message-content {
            background-color: #bbdefb;
        }

        .message .username {
            font-size: 12px;
            font-weight: bold;
            margin-bottom: 5px;
            color: #616161;
        }

        /* Chat Footer */
        .chat-footer {
            padding: 15px;
            border-top: 1px solid #e0e0e0;
            display: flex;
            align-items: center;
            background-color: #ffffff;
        }

        .message-input {
            flex: 1;
            padding: 12px;
            border: 1px solid #e0e0e0;
            border-radius: 25px;
            outline: none;
            margin-right: 10px;
            font-size: 14px;
            transition: border-color 0.3s;
        }

        .message-input:focus {
            border-color: #64b5f6;
        }

        .send-button {
            padding: 10px 25px;
            background-color: #42a5f5;
            color: #ffffff;
            border: none;
            border-radius: 25px;
            font-size: 14px;
            font-weight: bold;
            cursor: pointer;
            transition: background-color 0.3s, transform 0.2s;
        }

        .send-button:hover {
            background-color: #1e88e5;
            transform: scale(1.05);
        }
    </style>
</head>
<body>
    <!-- Sidebar -->
    <div class="sidebar">
        <div class="sidebar-header">Contacts</div>
        <div class="contact-list">
            <div class="contact-item">
                <div class="contact-avatar">G</div>
                <div class="contact-name">Group Chat</div>
            </div>
            <div class="contact-item">
                <div class="contact-avatar">U</div>
                <div class="contact-name">User 2</div>
            </div>
        </div>
    </div>

    <!-- Chat Area -->
    <div class="chat-area">
        <div class="chat-header">Group Chat</div>
        <div class="messages">
            <div class="message received">
                <div class="avatar">U1</div>
                <div>
                    <div class="username">User 1</div>
                    <div class="message-content">Hello, everyone!</div>
                </div>
            </div>
            <div class="message sent">
                <div class="avatar">ME</div>
                <div>
                    <div class="message-content">Hi, User 1!</div>
                </div>
            </div>
            <div class="message received">
                <div class="avatar">U2</div>
                <div>
                    <div class="username">User 2</div>
                    <div class="message-content">Good morning, all!</div>
                </div>
            </div>
        </div>
        <div class="chat-footer">
            <input type="text" class="message-input" placeholder="Type a message..." />
            <button class="send-button">Send</button>
        </div>
    </div>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

Top comments (0)