Hoe - Contactchips
Leer hoe u contactchips maakt met CSS.
Contactchips
John Doe
Jane Row
×
Contactchips maken
Stap 1) HTML toevoegen:
Voorbeeld
<div class="chip">
<img src="img_avatar.jpg" alt="Person"
width="96" height="96">
John Doe
</div>
Stap 2) CSS toevoegen:
Voorbeeld
.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%;
}
Afsluitbare contactchips
Om de contact-chip te sluiten/verbergen, voegt u een element toe met een onclick-gebeurtenisattribuut dat zegt: "wanneer u op mij klikt, verberg mijn bovenliggende element" - dat is de container div (class="chip").
Voorbeeld
<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: Gebruik de HTML-entiteit " ×
" om de letter "x" te maken.
Stijl vervolgens de sluitknop:
Voorbeeld
.closebtn {
padding-left: 10px;
color: #888;
font-weight: bold;
float: right;
font-size: 20px;
cursor: pointer;
}
.closebtn:hover
{
color: #000;
}