Tailwind CSS背景色类不生效但内联样式正常的问题求助
问题根源:HTML属性拼写错误
你遇到的问题是拼写错误——在不生效的代码中,你把HTML的class属性写成了clas(少了最后一个字母s)。这个错误导致浏览器无法识别bg-rose-900这个Tailwind类,所以背景色样式没有被应用。
内联样式能生效是因为它直接写在style属性中,不受clas这个错误属性的影响。
修正后的代码:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <script src="https://cdn.tailwindcss.com"></script> <title>Testing Tailwind</title> </head> <body class="h-screen"> <div class="h-full"> <!-- 修正clas为class --> <div class="h-full bg-rose-900"> <h1 class="text-blue-900 text-center text-4xl">Boards</h1> <p>Test</p> </div> </div> </body> </html>
内容的提问来源于stack exchange,提问作者Mr-DillinG
相关产品推荐
相关产品推荐

