#09 Chat

Preview

Hello Robert! How are you?
today, 20:15
Hello, I'm fine, thanks!
today, 20:15
Do you want to play tennis this afternoon?
today, 20:15
Hmmmm...today it's raining.
today, 20:15

HTML

SCSS


*, ::after, ::before {
  box-sizing: border-box;
}

/* css element */

@import "https://fonts.googleapis.com/css2?family=Roboto:wght@400;700;900&display=swap";

.chat {
  font-family: 'Roboto', sans-serif;
  background-color: #ffffff;
  border-radius: 30px;
  box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 320px;
  padding: 15px;

  .chat-header {
    margin-bottom: 15px;
    
    .photo {
      width: 46px;
      height: 46px;
      margin: 0 auto;
      border-radius: 100%;
      overflow: hidden;
      
      img {
        width: 100%;
        height: auto;
      }
    }
  }

  .chat-scroll {
    height: 100%;
    max-height: 350px;
    overflow-y: auto;
    margin-bottom: 15px;
  }

  .message-block {
    position: relative;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    -ms-flex-align: center;
    align-items: center;
    width: 100%;
    margin-bottom: 10px;
    
    .message {
      padding: 12px;
      max-width: 70%;
      font-size: 14px;
      line-height: 22px;
      font-weight: 400;
      color: #162B39;
    }
    
    .date {
      width: 100%;
      font-size: 11px;
      color: #95a5a6;
      margin-top: 5px;
    }
  }

  .message-block.out {
    justify-content: flex-start;
    justify-content: flex-end;
    
    .message {
      color: #ffffff;
      background-color: #5d1cf1;
      -webkit-border-radius: 15px;
      -webkit-border-bottom-right-radius: 0;
      -moz-border-radius: 15px;
      -moz-border-radius-bottomright: 0;
      border-radius: 15px;
      border-bottom-right-radius: 0;
    }
    
    .date {
      text-align: right;
    }
  }

  .message-block.in {
    .message {
      background-color: #e1e2e8;
      -webkit-border-radius: 15px;
      -webkit-border-bottom-left-radius: 0;
      -moz-border-radius: 15px;
      -moz-border-radius-bottomleft: 0;
      border-radius: 15px;
      border-bottom-left-radius: 0;
    }
  }

  .chat-text {
    position: relative;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    -ms-flex-align: center;
    align-items: center;
    justify-content: space-between;
    
    .input-text {
      background-color: #e8e7e9;
      border-radius: 22px;
      width: calc(100% - 60px);
      height: 44px;
      position: relative;
      display: -ms-flexbox;
      display: flex;
      -ms-flex-wrap: wrap;
      flex-wrap: wrap;
      -ms-flex-align: center;
      align-items: center;
      
      button {
        border: none;
        background: none;
        padding: 0;
        outline: none;
        
        &:hover {
          background: none;
          box-shadow: none;
          outline: none;
          
          svg {
            fill: #000000;
            vertical-align: middle;
          }
        }
        
        svg {
          fill: #162B39;
          width: 30px;
          vertical-align: middle;
        }
      }
      
      input {
        width: calc(100% - 88px);
        height: 44px;
        border: none;
        background-color: #e8e7e9;
        font-size: 14px;
        padding: 0;
        margin: 0;
        
        &:focus {
          box-shadow: none;
          outline: none;
        }
      }
    }
    
    button {
      width: 44px;
      height: 44px;
      border-radius: 100%;
      background-color: #8580e5;
      border: none;
      cursor: pointer;
      padding: 0;
      outline: none;
      
      &:hover {
        background-color: #5d1cf1;
      }
      
      svg {
        fill: #ffffff;
        width: 30px;
        vertical-align: middle;
      }
    }
  }
}


Notes

In the code you can replace the images, icons and font. For icons and font you may have to change the size in the css.

Help the Project

Your help is important for the success of this project. We will make this project grow for everyone.