So. I'm making a chat messaging system's UI. How can I select the last item in a group of "messages" with the same class using CSS (Probably impossible) or JQuery ( maybe possible )?
I want to select the elements circled in red.
Code:
#chatmsgs {
margin: 0;
padding: 0;
list-style: none;
overflow: scroll;
width: 100%;
height: 100%;
}
ul li {
display:inline-block;
clear: both;
padding:8px;
padding-top:5px;
padding-bottom:5px;
border-radius: 30px;
margin-bottom: 2px;
font-family: Helvetica, Arial, sans-serif;
}
.msg-them{
background:#eee;
float: left;
}
.msg-you{
float: right;
background: #0084ff;
color: #fff;
}
.msg-them + .msg-you{
border-bottom-right-radius: 5px;
}
.msg-you + .msg-you{
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
}
.msg-you:last-of-type {
border-bottom-right-radius: 30px;
}
<ul id="chatmsgs"><li class="msg-them">b has joined</li><li class="msg-you">a</li><li class="msg-you">a</li><li class="msg-you">a</li><li class="msg-you">a</li><li class="msg-you">a</li><li class="msg-them">b: b</li><li class="msg-them">b: b</li><li class="msg-them">b: b</li><li class="msg-them">b: b</li><li class="msg-them">b: b</li><li class="msg-you">a</li><li class="msg-you">a</li><li class="msg-you">a</li></ul>