Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="center-div">
  <div class="container">
  <div class="grid grid--user-profile">
    <div class="grid__column">
    <div class="card card--user-profile ">
      <div class="card--user-profile__cover"></div>
      <div class="card-body">
        <figure class="avatar avatar--online">
          <div class="avatar__thumbnail">
            <img src="https://randomuser.me/api/portraits/women/81.jpg" class="avatar__image" alt="Picture of avatar">

          </div>
          <figcaption class="avatar__meta">
            <h5 class="avatar__title js-user-name">Kelly Shaw</h5>
            <div class="avatar__summery js-multiline-truncate">Team Lead/ Sr. Laravel Developer at XZY Company </div>

          </figcaption>
        </figure>

        <figure class="mutual-connection mb-4">
          <img src="https://randomuser.me/api/portraits/women/96.jpg" class="mutual-connection__image" alt="Picture of user">
          <img src="https://randomuser.me/api/portraits/men/81.jpg" class="mutual-connection__image" alt="Picture of user">
          <img src="https://randomuser.me/api/portraits/men/51.jpg" class="mutual-connection__image" alt="Picture of user">
          <figcaption class="mutual-connection__caption">10 mutual connections</figcaption>
        </figure>

        <a href="#" role="button" class="btn btn-outline-dark">Invite Now</a>
      </div>

    </div>
      </div>
    <div class="grid__column">
    <div class="card card--user-profile ">
      <div class="card--user-profile__cover"></div>
      <div class="card-body">
        <figure class="avatar avatar--online">
          <div class="avatar__thumbnail">
            

          </div>
          <figcaption class="avatar__meta">
            <h5 class="avatar__title js-user-name">Kelly Shaw</h5>
            <div class="avatar__summery js-multiline-truncate">Team Lead/ Sr. Laravel Developer at XZY Company </div>

          </figcaption>
        </figure>

        <figure class="mutual-connection mb-4">
          <img src="https://randomuser.me/api/portraits/women/96.jpg" class="mutual-connection__image" alt="Picture of user">
          <img src="https://randomuser.me/api/portraits/men/81.jpg" class="mutual-connection__image" alt="Picture of user">
          <img src="https://randomuser.me/api/portraits/men/51.jpg" class="mutual-connection__image" alt="Picture of user">
          <figcaption class="mutual-connection__caption">10 mutual connections</figcaption>
        </figure>

        <a href="#" role="button" class="btn btn-outline-dark">Invite Now</a>
      </div>

    </div>
      </div>
     <div class="grid__column">
    <div class="card card--user-profile ">
      <div class="card--user-profile__cover"></div>
      <div class="card-body">
        <figure class="avatar avatar--online">
          <div class="avatar__thumbnail">
            <img src="https://randomuser.me/api/portraits/women/81.jpg" class="avatar__image" alt="Picture of avatar">

          </div>
          <figcaption class="avatar__meta">
            <h5 class="avatar__title js-user-name">Kelly Shaw</h5>
            <div class="avatar__summery js-multiline-truncate">Team Lead/ Sr. Laravel Developer at XZY Company </div>

          </figcaption>
        </figure>

        <figure class="mutual-connection mb-4">
          <img src="https://randomuser.me/api/portraits/women/96.jpg" class="mutual-connection__image" alt="Picture of user">
          <img src="https://randomuser.me/api/portraits/men/81.jpg" class="mutual-connection__image" alt="Picture of user">
          <img src="https://randomuser.me/api/portraits/men/51.jpg" class="mutual-connection__image" alt="Picture of user">
          <figcaption class="mutual-connection__caption">10 mutual connections</figcaption>
        </figure>

        <a href="#" role="button" class="btn btn-outline-dark">Invite Now</a>
      </div>

    </div>
      </div>
     <div class="grid__column">
    <div class="card card--user-profile ">
      <div class="card--user-profile__cover"></div>
      <div class="card-body">
        <figure class="avatar avatar--online">
          <div class="avatar__thumbnail">
            <img src="https://s.cdpn.io/profiles/user/1861956/80.jpg" class="avatar__image" alt="Picture of avatar">

          </div>
          <figcaption class="avatar__meta">
            <h5 class="avatar__title js-user-name">Shrawan Kumar</h5>
            <div class="avatar__summery js-multiline-truncate">Team Lead/ Sr. Laravel Developer at XZY Company </div>

          </figcaption>
        </figure>

        <figure class="mutual-connection mb-4">
          <img src="https://randomuser.me/api/portraits/women/96.jpg" class="mutual-connection__image" alt="Picture of user">
          <img src="https://randomuser.me/api/portraits/men/81.jpg" class="mutual-connection__image" alt="Picture of user">
          <img src="https://randomuser.me/api/portraits/men/51.jpg" class="mutual-connection__image" alt="Picture of user">
          <figcaption class="mutual-connection__caption">10 mutual connections</figcaption>
        </figure>

        <a href="#" role="button" class="btn btn-outline-dark">Invite Now</a>
      </div>

    </div>
      </div>
 
  </div>

</div>
</div>
              
            
!

CSS

              
                //mixin partial
//size mixin
@mixin size($width, $height:$width) {
  width: $width;
  height: $height;
}
//truncate mixing
@mixin truncate($max-width:null) {
  @if $max-width {
    max-width: $max-width;
  }
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

//Placeholder Partial
%round-circle {
  border-radius: 50%;
  overflow: hidden;
}

//Global Setting
@import url("https://fonts.googleapis.com/css?family=Poppins:300,400,500,600");
$green: #2ecc71;
$textcolor: #00120b;
$lightgray: #5c6863;
$font-family: "Poppins", sans-serif;
 $colors:  #F44336, #E91E63, #9C27B0, #009688, #3F51B5, #2196F3, #4CAF50, #FF5722,  #9E9E9E, #607D8B ;

body {
  font-family: $font-family;
  padding:2rem 0;
}
.center-div {
  display:flex;
  height:100vh;
  align-items:center;
  justify-content:center;
}

//avatar Compoment
.avatar {
  $p: &;
  --size: 6rem; //css variables/ custom property
  $thumbnail: var(--size, 6rem); // fallback values assigned to custom property
  &__thumbnail {
    position: relative;
    display: inline-flex;
     @include size($thumbnail);
    background-color: #eee;
    border-radius:50%;
    @at-root #{$p}--online & {
      &:after {
        @include size(1rem);
        content: " ";
        position: absolute;
        right: 0px;
        bottom: 6px;
        background-color: $green;
        border:2px solid white;
        @extend %round-circle;
         z-index:1;
      }
      &:before  {
        content:attr(data-name);
        position:absolute;
        top:50%;
        left:50%;
        transform:translateX(-50%) translateY(-50%);
        color:white;
        font-size:1.5rem;
        z-index:0;
        letter-spacing:1.5px;
      }
    }
  }
  &__image {
    @include size($thumbnail);
    @extend %round-circle;
    z-index:1;
  }

  //avatar meta
  &__title {
    font-weight: 600;
    @include truncate();
  }
  &__summery {
    color: $lightgray;
  }
}

//Mutual Connection Component
.mutual-connection {
  $p: &;
  --size: 3rem; //css variables/ custom property
  $thumbnail: var(--size, 6rem);
  $overlapping-space: 1.5rem;
  margin-left: $overlapping-space;
  $color: #05668d;
  display: flex;
  align-items: center;
  color: $color;
  &__image {
    @include size($thumbnail);
    @extend %round-circle;
    border: 2px solid white;
    margin-left: -$overlapping-space;
    flex: 0 0 auto;
    box-sizing:border-box;
  }
  &__caption {
    padding-left: $overlapping-space/2;
  }
}

//bootstrap card modifier : user-profile
.card {
  &--user-profile {
    $p: &;
    // padding:1.5em;
    box-shadow: 0px 1px 10px 0px rgba(black, 0.1);
    position:relative;
    $cover-height:6rem - 1.25rem;
    border-radius:10px;
    overflow:hidden;
    transition:all 0.3s;
    transform:translateY(0px);
    &:hover {
      transform:translateY(-15px);
      box-shadow: 0px 6px 15px 0px rgba(black, 0.3);
    }

    &__cover {
      height: $cover-height;
      opacity:0.5;     
      width:100%;
      position:absolute;
      top:0;
       @for $i from 1 through length($colors) {
        @at-root .grid__column:nth-of-type(#{length($colors)}n+#{$i}) & {
          background-color: nth($colors, $i);
        }
      }
    }
  
  .avatar {
    position:relative;
    // margin-top:-6rem + 1.25rem;
    &__thumbnail {
       @for $i from 1 through length($colors) {
        @at-root .grid__column:nth-of-type(#{length($colors)}n+#{$i}) & {
          background-color: nth($colors, $i);
        }
      }
    }
  }
  }
&.text-center {
  .mutual-connection {
    justify-content:center;
  }
}
}


.grid{
  $p:&;
  &--user-profile {
      display:flex;
  flex-wrap:wrap;
  margin:-15px;
  justify-content:center;
 
    #{$p}__column {
    flex: 1 1 100%;
    padding:15px;
     @media(min-width:576px){
      flex:1 1 50% ;
    }
    @media(min-width:767px){
      flex:0 1 33.33% ;
    }
    @media(min-width:992px){
      flex:0 1 25% ;
    }
  }
  }
   
  
  
}
              
            
!

JS

              
                 let truncateText = document.querySelectorAll(".js-multiline-truncate"); 

 



for (i = 0; i < truncateText.length; i++) { 
  // console.log(truncateText[i][0]); 
  let truncateTextEach =truncateText[i];
   $clamp(truncateTextEach, {clamp: 2});  
 
}

let names= document.querySelectorAll('.js-user-name');
names.forEach((name, i) => {
  let shortName = name.innerText.split(' ').map(w => w[0]).join("");
  document.getElementsByClassName("avatar__thumbnail")[i].dataset.name = shortName;
})
 


 
              
            
!
999px

Console