我在計算機上將 CSS 鏈接到 HTML 時遇到問題。我的 html 檔案具有 CSS 檔案的正確鏈接和名稱,但是當我在 chrome 中通過 HTML 檔案打開時,沒有樣式。如果我之后打開開發工具并轉到源代碼,即使專案檔案夾中有 json、css、html 和 js 檔案,檔案夾中也只會顯示我的 js 和 html 檔案。CSS檔案名為index.css,js檔案名為index.js,html檔案名為index.html。如果您知道可能出了什么問題,請告訴我。我在這里運行了這兩個檔案,它們在這里作業,但當我嘗試在 chrome 上運行我的 html 檔案時卻沒有。
代碼:
body {
margin: 0;
padding: 10px;
font-family: Arial, Helvetica, sans-serif;
min-width: 400px;
}
input {
width: 100%;
padding: 10px;
box-sizing: border-box;
border: 1px solid #5f9341;
margin-bottom: 4px;
}
button {
background: #5f9341;
color: white;
padding: 10px 20px;
border: 1px solid #5f9341;
font-weight: bold;
}
#delete-btn {
background: white;
color: #5f9341;
}
ul {
margin-top: 20px;
list-style: none;
padding-left: 0;
}
li {
margin-top: 5px;
}
a {
color: #5f9341;
}
<!DOCTYPE html>
<html lang="en">
<head>
<link src="index.css" ref="stylesheet" type: "text/css">
</head>`enter code here`
<body>
<input type="text" id="input-el">
<button id="input-btn">SAVE INPUT</button>
<button id="tab-btn">SAVE TAB</button>
<button id="delete-btn">DELETE</button>
<ul id="ul-el">
</ul>
<script src="index.js"></script>
</body>
</html>
uj5u.com熱心網友回復:
而不是“src”,它需要是“href”,并且“type:”必須是“type =”
<link href="index.css" rel="stylesheet" type="text/css">
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/492117.html
