Tailwind CSS-Installation (CDN)
Wenn Sie es nur ausprobieren möchten, können Sie den CDN-Link direkt einbinden:
Verwenden Sie die offizielle CDN-Bibliothek, die URL lautet wie folgt:
<script src="https://cdn.tailwindcss.com"></script>
Verwenden Sie die CDN-Bibliothek von jsDelivr, die URL lautet wie folgt:
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@3.3.0/dist/tailwind.min.css" rel="stylesheet">
Verwenden Sie es auf diese Weise:
- Vorteile:Keine Konfiguration erforderlich, geeignet für schnelle Entwicklung und Demonstration.
- Nachteile: Stile können nicht angepasst werden, und die Dateigröße ist relativ groß.
Anwendungsbeispiele
Das folgende Beispiel gibt Hello, world! aus.
Beispiel
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<h1 class="text-3xl font-bold underline">
Hallo Welt!
</h1>
</body>
</html>
Ausprobieren »
Bearbeite das tailwind.config-Objekt, um deine eigene Konfiguration zu definieren:
Beispiel
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
clifford: '#da373d',
}
}
}
}
</script>
</head>
<body>
<h1 class="text-3xl font-bold underline text-clifford">
Hallo Welt!
</h1>
</body>
</html>
Ausprobieren »
Verwende type="text/tailwindcss", um eigenes CSS hinzuzufügen:
Beispiel
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
<style type="text/tailwindcss">
@layer utilities {
.content-auto {
content-visibility: auto;
}
}
</style>
</head>
<body>
<div class="lg:content-auto">
<!-- ... -->
</div>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
<style type="text/tailwindcss">
@layer utilities {
.content-auto {
content-visibility: auto;
}
}
</style>
</head>
<body>
<div class="lg:content-auto">
<!-- ... -->
</div>
</body>
</html>
Verwenden Sie den Parameter plugins, um die zu verwendenden Plugins festzulegen, wie z. B. forms und typography:
Beispiel
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio,line-clamp,container-queries"></script>
</head>
<body>
<div class="prose">
<!-- ... -->
</div>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio,line-clamp,container-queries"></script>
</head>
<body>
<div class="prose">
<!-- ... -->
</div>
</body>
</html>