我有以下的HTML代碼:CSS屬性的身體需要的項重要關鍵字發生
<!DOCTYPE html>
<html>
<head>
<title>Project Web</title>
</head>
<body>
<h1>Hello, World!</h1>
</body>
<link href="index_style.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
</html>
下面CSS(在index_style.css文件):
body {
background-color: black !important;
color: white !important;
}
正如你可以說,只有在後面跟着!important關鍵字時,「背景顏色」和「顏色」屬性纔會發生。這是爲什麼發生?
由於樣式是級聯的,所以瀏覽器採用更詳細或最後一種Style規則並應用它。因此,如果您在引導後包含css,則您的樣式是瀏覽器找到的最後一個樣式,因此它們將覆蓋引導規則。 –