Created
June 5, 2024 10:49
-
-
Save momin-riyadh/e821fd0d5a4191f9a3a0b718ee1e95bc to your computer and use it in GitHub Desktop.
Comments and nested reply user interface
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="chat-container"> | |
<div class="message" id="message-1"> | |
<img src="https://picsum.photos/40/40" alt="User 1" class="avatar"> | |
<div class="message-content"> | |
<h6>Momin Riyadh</h6> | |
<p>Hello, this is the first message.</p> | |
</div> | |
<div class="replies"> | |
<div class="message reply" id="reply-1-1"> | |
<img src="https://picsum.photos/40/40" alt="User 2" class="avatar"> | |
<div class="message-content">This is a reply to the first message.</div> | |
<div class="replies"> | |
<div class="message reply" id="reply-1-1-1"> | |
<img src="https://picsum.photos/40/40" alt="User 3" class="avatar"> | |
<div class="message-content">This is a nested reply.</div> | |
</div> | |
</div> | |
</div> | |
<div class="message reply" id="reply-1-2"> | |
<img src="https://picsum.photos/40/40" alt="User 4" class="avatar"> | |
<div class="message-content">Another reply to the first message.</div> | |
</div> | |
</div> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* styles.css */ | |
body { | |
font-family: Arial, sans-serif; | |
margin: 0; | |
padding: 20px; | |
} | |
.chat-container { | |
max-width: 600px; | |
margin: 0 auto; | |
background-color: #fff; | |
border-radius: 10px; | |
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | |
padding: 20px; | |
} | |
.message { | |
position: relative; | |
padding: 10px 20px 10px 60px; /* Adjust padding to make space for the avatar */ | |
border-radius: 5px; | |
margin-bottom: 10px; | |
} | |
.message.reply { | |
} | |
.avatar { | |
position: absolute; | |
top: 0; | |
left: 10px; | |
width: 40px; | |
height: 40px; | |
border-radius: 50%; | |
border: 2px solid #ccc; | |
} | |
.message-content { | |
position: relative; | |
z-index: 2; | |
} | |
.replies { | |
margin-top: 30px; | |
margin-left: 25px; /* Align nested replies with avatars */ | |
} | |
.message::before { | |
content: ''; | |
position: absolute; | |
left: 30px; /* Align with the center of the avatar */ | |
top: 0; | |
bottom: 42px; | |
width: 1px; | |
background: #ddd; | |
} | |
.message.reply::before { | |
background: #dddddd; | |
} | |
.message.reply::after { | |
content: ""; | |
position: absolute; | |
inset-inline-start: 0px; | |
left: -55px; | |
top: 5px; | |
height: 25px; | |
width: 60px; | |
-webkit-border-start: 1px solid #ddd; | |
border-inline-start: 1px solid #ddd; | |
border-bottom: 1px solid #dddddd; | |
background: transparent; | |
border-end-start-radius: 10px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment