Deskripsi:
PSEUDO-CLASS.html nama file nya
Kode Program:
Css
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PSEUDO-CLASS</title>
<style>
/* PSEUDO-CLASS LINK */
/* LINK */
a:link{
color: hotpink;
}
/* END LINK */
/* visited */
a:visited{
color: greenyellow;
}
/* end visited */
/*END PSEUDO-CLASS LINK */
/* ----------------------------------------------------------------------- */
/* PSEUDO-CLASS hover */
.hover .contoh-percobaan{
width: 150px;
height: 150px;
border: 2px solid black;
background-color: yellowgreen;
}
.hover .contoh-percobaan:hover{
background-color: hotpink;
border-radius: 50%;
transition: all 0.5s;
}
/*END PSEUDO-CLASS hover */
/* ----------------------------------------------------------------------- */
li{
padding: 10px;
border: 1px solid black;
}
/* PSEUDO-CLASS first-child */
.first-child li:first-child{
background-color: hotpink;
}
/*END PSEUDO-CLASS first-child */
/* ----------------------------------------------------------------------- */
/* PSEUDO-CLASS last-child */
.last-child li:last-child{
background-color: hotpink;
}
/*END PSEUDO-CLASS last-child */
/* ----------------------------------------------------------------------- */
/* PSEUDO-CLASS nth-child */
/* ODD = GANJIL */
.nth-child li:nth-child(odd){
background-color: hotpink;
}
/* EVEN = GENAP */
.nth-child li:nth-child(even){
background-color: yellow;
}
/* NILAI DI TENTUKAN SENDIRI */
.nth-child li:nth-child(5){
background-color: green;
}
/*END PSEUDO-CLASS nth-child */
</style>
</head>
<body>
<div class="link">
<h1>PSEUDO-CLASS :link</h1>
<a href="">Contoh percobaan visited (sudah pernah di kunjungi)</a>
<br>
<a href="belum-pernah.html">Contoh Percobaan Link (belum di kunjungi)</a>
<hr>
</div>
<div class="hover">
<h1>PSEUDO-CLASS :hover</h1>
<div class="contoh-percobaan"></div>
<hr>
</div>
<div class="first-child">
<h1>PSEUDO-CLASS :first-child</h1>
<ul>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>
<hr>
</div>
<div class="nth-child">
<h1>PSEUDO-CLASS :nth-child</h1>
<ul>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
<li>item 4</li>
<li>item 5</li>
</ul>
<hr>
</div>
<div class="last-child">
<h1>PSEUDO-CLASS :last-child</h1>
<ul>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>
<hr>
</div>
</body>
</html>
Geser ke samping untuk lihat kode lengkap
Perhatian: Kode ini hanya untuk dilihat, tidak dapat disalin.