0

I have a chat, and I want to add the picture of the user by the side of the div, but I tried and I don't have success.Actually the image is in the bottom of the div, give a look at the image and see where the image is and where I want to add the image. I don't have any ideia to solve it, can someone help me? I'm using bootstrap

.message-content {
  border-radius: .625rem .625rem 2px .625rem;
  display: inline-block;
  flex-wrap: wrap;
  width: 20%;
  padding: 1.125rem;
}

.message-right .avatar {
  -webkit-box-ordinal-group: 3;
  -ms-flex-order: 2;
  order: 2;
}

.message .avatar {
  height: 2rem;
  min-height: 2rem;
  width: 2rem;
  min-width: 2rem;
}

.avatar {
  border-radius: 50%;
  line-height: 0;
  position: relative;
}

.avatar>img {
  height: 2rem;
  min-height: 2rem;
  width: 2rem;
  min-width: 2rem
}
<div class="message-content bg-primary text-white">
  <h6 class="mb-2 black">New User</h6>
  <div>
    Hello! This is my first message content in CSS
  </div>
</div>
<div class="avatar avatar-sm ml-4 ml-lg-5 d-none d-lg-block">
  <img class="avatar-img" src="https://www.kindpng.com/picc/m/495-4952535_create-digital-profile-icon-blue-user-profile-icon.png" alt="">
</div>

output

cloned
  • 6,346
  • 4
  • 26
  • 38

1 Answers1

-1

.message-container {
  width: auto;
  display: inline-block;
  position:relative;
}
.message-content{
  float:left;
  color: #fff;
  background: #477AFF;
  border-radius: .625rem .625rem 2px .625rem;
  display: inline-block;
  flex-wrap: wrap;
  width: 77%;
  padding: 1.125rem;
}
.message-right .avatar{
  -webkit-box-ordinal-group: 3;
  -ms-flex-order: 2;
  order: 2;
}
.message .avatar{
  height: 2rem;
  min-height: 2rem;
  width: 2rem;
  min-width: 2rem;
}
.avatar{
  float: right;
  border-radius: 50%;
  line-height: 0;
  position: absolute;
  right:0;
  bottom:0;
}
.avatar>img{
  height: 2rem;
  min-height: 2rem;
  width: 2rem;
  min-width: 2rem
}
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <div class='message-container'>
    <div class="message-content bg-primary text-white">
      <h6 class="mb-2 black">New User</h6>
      <div>
        <p>Hello! This is my first message content in CSS</p>
      </div>
  </div>
    <div class="avatar avatar-sm ml-4 ml-lg-5 d-none d-lg-block">
      <img class="avatar-img" src="https://www.kindpng.com/picc/m/495-4952535_create-digital-profile-icon-blue-user-profile-icon.png" alt="">
    </div>
  </div>
  
</body>
</html>
Zayn
  • 741
  • 1
  • 5
  • 22