how to style chat-bubble in iphone classic style using css only

后端 未结 4 1910
星月不相逢
星月不相逢 2021-02-04 20:52

I trying to create a html page which looks like similar to Messages(thread view) just as in our android and iphone devices.

Here is what i have coded

Css styles:

4条回答
  •  终归单人心
    2021-02-04 21:20

    The HTML

    Hello, how's it going?
    Great thanks!
    How about you?

    The CSS

    body {
      font-family: helvetica;
      display: flex ;
      flex-direction: column;
      align-items: center;
    }
    
    .chat {
      width: 300px;
      border: solid 1px #EEE;
      display: flex;
      flex-direction: column;
      padding: 10px;
    }
    
    .messages {
      margin-top: 30px;
      display: flex;
      flex-direction: column;
    }
    
    .message {
      border-radius: 20px;
      padding: 8px 15px;
      margin-top: 5px;
      margin-bottom: 5px;
      display: inline-block;
    }
    
    .yours {
      align-items: flex-start;
    }
    
    .yours .message {
      margin-right: 25%;
      background-color: #EEE;
      position: relative;
    }
    
    .yours .message.last:before {
      content: "";
      position: absolute;
      z-index: 0;
      bottom: 0;
      left: -7px;
      height: 20px;
      width: 20px;
      background: #EEE;
      border-bottom-right-radius: 15px;
    }
    .yours .message.last:after {
      content: "";
      position: absolute;
      z-index: 1;
      bottom: 0;
      left: -10px;
      width: 10px;
      height: 20px;
      background: white;
      border-bottom-right-radius: 10px;
    }
    
    .mine {
      align-items: flex-end;
    }
    
    .mine .message {
      color: white;
      margin-left: 25%;
      background: rgb(0, 120, 254);
      position: relative;
    }
    
    .mine .message.last:before {
      content: "";
      position: absolute;
      z-index: 0;
      bottom: 0;
      right: -8px;
      height: 20px;
      width: 20px;
      background: rgb(0, 120, 254);
      border-bottom-left-radius: 15px;
    }
    
    .mine .message.last:after {
      content: "";
      position: absolute;
      z-index: 1;
      bottom: 0;
      right: -10px;
      width: 10px;
      height: 20px;
      background: white;
      border-bottom-left-radius: 10px;
    }
    

    https://codepen.io/swards/pen/gxQmbj

提交回复
热议问题