!DOCTYPE html> ChatGPT Chatbox
ChatGPT
body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    margin: 0;
    padding: 0;
}

.chat-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.chat-box {
    width: 300px;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-shadow: 0px 0px 5px #ccc;
}

.chat-header {
    background-color: #007bff;
    color: #fff;
    padding: 10px;
    text-align: center;
    font-weight: bold;
}

.chat-messages {
    padding: 10px;
    min-height: 200px;
    max-height: 300px;
    overflow-y: auto;
    border-bottom: 1px solid #ccc;
}

.chat-input {
    display: flex;
    padding: 10px;
    background-color: #f9f9f9;
}

input[type="text"] {
    flex: 1;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 5px;
    outline: none;
}

button {
    background-color: #007bff;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 5px 10px;
    margin-left: 10px;
    cursor: pointer;
}
const chatMessages = document.getElementById(‘chat-messages’); const userInput = document.getElementById(‘user-input’); const sendButton = document.getElementById(‘send-button’); sendButton.addEventListener(‘click’, () => { const userMessage = userInput.value; if (userMessage.trim() === ”) return; // Display user message displayMessage(userMessage, true); // Simulate ChatGPT response (you can replace this with an actual API call to ChatGPT) const chatGPTResponse = “This is a ChatGPT response.”; setTimeout(() => displayMessage(chatGPTResponse, false), 1000); // Clear user input userInput.value = ”; }); function displayMessage(message, isUser) { const messageDiv = document.createElement(‘div’); messageDiv.className = isUser ? ‘user-message’ : ‘chatgpt-message’; messageDiv.textContent = message; chatMessages.appendChild(messageDiv); // Scroll to the bottom of the chat container chatMessages.scrollTop = chatMessages.scrollHeight; }