Learn how to create contact chips with CSS.
<div class="chip">
<img src="img_avatar.jpg" alt="Person" width="96" height="96">
John Doe
</div>
.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>
Tip: Use the HTML entity "×
" 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 »
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!