HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Learn how to create contact chips with CSS
Step 1) Add HTML:
<div class="chip">
<img src="img_avatar.jpg" alt="Person"
width="96" height="96">
John Doe
</div>
Step 2) Add CSS:
.chip {
display: inline-block;
padding: 0 25px;
height: 50px;
font-size: 16px;
line-height: 50px;
border-radius: 25px;
background-color: #f1f1f1;
}
.chip img {
float: left;
margin: 0 10px 0 -25px;
height: 50px;
width: 50px;
border-radius: 50%;
}
Try it Yourself »
To close/hide the contact chip, add an element with an onclick event attribute that says "when you click you on me, hide my parent element" - which is the container div (class="chip").
<div class="chip">
<img src="img_avatar.jpg" alt="Person"
width="96" height="96">
John Doe
<span class="closebtn"
onclick="this.parentElement.style.display='none'">×</span>
</div>
×
" to create the letter "x".
Next, style the close button:
.closebtn {
padding-left: 10px;
color: #888;
font-weight: bold;
float: right;
font-size: 20px;
cursor: pointer;
}
.closebtn:hover
{
color: #000;
}
Try it Yourself »