43 lines
1.0 KiB
HTML
43 lines
1.0 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>classList</title>
|
|
<style>
|
|
body { font-family: system-ui, sans-serif; padding: 1.5rem; }
|
|
h3 { margin: 0.5rem 0 0.4rem; font-size: 0.85rem; color: #6b7280; text-transform: uppercase; letter-spacing: 0.04em; }
|
|
.box {
|
|
padding: 16px 20px;
|
|
border: 2px solid #9ca3af;
|
|
border-radius: 6px;
|
|
background: #f3f4f6;
|
|
margin-bottom: 14px;
|
|
}
|
|
.box.aktiv {
|
|
border-color: #16a34a;
|
|
background: #dcfce7;
|
|
color: #14532d;
|
|
font-weight: 600;
|
|
box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2);
|
|
}
|
|
button {
|
|
font: inherit;
|
|
padding: 8px 14px;
|
|
border-radius: 6px;
|
|
border: 1px solid #9ca3af;
|
|
background: #fff;
|
|
cursor: pointer;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h3>.box ohne Klasse</h3>
|
|
<div class="box">inaktiv</div>
|
|
|
|
<h3>.box mit classList.add("aktiv")</h3>
|
|
<div class="box aktiv">aktiv ✓</div>
|
|
|
|
<button>classList.toggle("aktiv")</button>
|
|
</body>
|
|
</html>
|