Sure! Here's a simple HTML, CSS, and JavaScript example of a basic chat interface. You can copy and paste this code into an .html file and open it in your browser to see it in action.
📁 Simple Chat Interface (HTML + CSS + JS)
.chat-container {
width: 400px;
background: #fff;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
display: flex;
flex-direction: column;
overflow: hidden;
}
.chat-header {
background: #4CAF50;
color: white;
padding: 10px;
text-align: center;
font-weight: bold;
}
.chat-messages {
flex: 1;
padding: 10px;
overflow-y: auto;
background: #f9f9f9;
}
.message {
margin: 5px 0;
padding: 8px 12px;
border-radius: 20px;
max-width: 70%;
clear: both;
}
.user {
background: #DCF8C6;
align-self: flex-end;
float: right;
}
.bot {
background: #e0e0e0;
align-self: flex-start;
float: left;
}
.chat-input {
display: flex;
border-top: 1px solid #ccc;
}
.chat-input input {
flex: 1;
padding: 10px;
border: none;
outline: none;
}
.chat-input button {
padding: 10px 15px;
background: #4CAF50;
color: white;
border: none;
cursor: pointer;
}
.chat-input button:hover {
background: #45a049;
}
How it works:
- The user types a message and clicks "Send".
- The message appears in the chat window.
- A simulated bot reply appears after a short delay.
Let me know if you'd like to connect this to a real backend or add more features like usernames, timestamps, or persistent chat history!