即使瀏覽器在源代碼中顯示 css 樣式,背景顏色也不會顯示。有什么想法嗎?
這是 HTML:'''
<div class="footer">
<li>© Cedar Flute, 2022.</li>
<li style="float:right">Web Design: Leagh Branner.</li>
</div>
'''
和 CSS:
'''
.footer {
list-style-type: none;
margin: 20px;
background-color: #009DDC;
}
'''
uj5u.com熱心網友回復:
您是否將 CSS 檔案鏈接到 HTML 檔案?
<head>
<link rel = "stylesheet" href = "styles.css">
</head>
在谷歌瀏覽器上,這段代碼對我來說很好。如果那里有更多代碼,請嘗試添加整個檔案,因為其余代碼中可能存在錯誤。
uj5u.com熱心網友回復:
它對我來說很好。你確定你的 CSS 檔案鏈接正確嗎?我的檔案在 CSS 檔案夾中,我在 HTML 頭中有這個
<link rel="stylesheet" href="css/index.css">
uj5u.com熱心網友回復:
我認為這樣的東西可能更接近你正在尋找的東西......
HTML:
<div class="footer">
<ul>
<li>© Cedar Flute, 2022.</li>
<li>Web Design: Leagh Branner.</li>
</ul>
</div>
CSS:
.footer {
background-color: #009DDC;
padding: 20px;
display: block;
overflow: hidden;
}
ul {
list-style-type: none;
}
li {
float: left;
margin-right: 20px;
}
uj5u.com熱心網友回復:
最好使用 flexbox。
<div class="footer">
<li>© Cedar Flute, 2022.</li>
<li>Web Design: Leagh Branner.</li>
</div>
.footer {
display: flex;
justify-content: space-between;
list-style-type: none;
margin: 20px;
background-color: #009ddc;
}
如果您仍想使用浮動(建議切換到 flexbox)-
<div class="footer">
<li style="float:right">Web Design: Leagh Branner.</li>
<li>© Cedar Flute, 2022.</li>
</div>
.footer {
list-style-type: none;
margin: 20px;
background-color: #009ddc;
overflow: auto;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/486793.html
