如何使背景顏色觸摸每一端。我對下面的 html 和 CSS 相當陌生,我有我為背景輸入的代碼。請讓我確切知道我需要在代碼中更改什么。我知道其中一些需要改變,我只是不知道我需要改變什么。
.black {
background-color: black;
font-size: 20px;
}
<div class="black">
<hr>
<h2 class="white">Documentation Examples</h2>
<a>
<ul class="documentations">
<li>
Savings or Checkings Accounts
</li>
<li>
Stocks, Dividends, Bonds or Debentures
</li>
<li>
Life Insurance Accounts
</li>
<li>
Escrow Accounts
</li>
<li>
Negotiable Instruments, Certified Checks, Money Orders, or Travelers Checks.
</li>
<li>
Safe Deposit Box Contents
</li>
<li>
Business Accounts
</li>
<li>
Corporation/Business Entity/Partnership
</li>
<li>
Governmental Agency Accounts
</li>
<li>
Miscellaneous Accounts
</li>
</ul>
</nav>
</a>
<br>
<br>
<br>
</div>
在此處輸入圖片說明
uj5u.com熱心網友回復:
將您的代碼嵌套在 a 中body并margin: 0;在您的樣式表中使用。見下文。
.black {
background-color: black;
font-size: 20px;
}
body {
margin: 0;
}
li {
color: white;
}
<body>
<div class="black">
<hr>
<h2 class="white">Documentation Examples</h2>
<a>
<ul class="documentations">
<li>
Savings or Checkings Accounts
</li>
<li>
Stocks, Dividends, Bonds or Debentures
</li>
<li>
Life Insurance Accounts
</li>
<li>
Escrow Accounts
</li>
<li>
Negotiable Instruments, Certified Checks, Money Orders, or Travelers Checks.
</li>
<li>
Safe Deposit Box Contents
</li>
<li>
Business Accounts
</li>
<li>
Corporation/Business Entity/Partnership
</li>
<li>
Governmental Agency Accounts
</li>
<li>
Miscellaneous Accounts
</li>
</ul>
</nav>
</a>
<br>
<br>
<br>
</div>
</body>
uj5u.com熱心網友回復:
.black {
background-color: black;
font-size: 20px;
color: white;
height: 100vh;
}
body {
margin: 0;
padding: 0;
}
uj5u.com熱心網友回復:
您的代碼是正確的,但您需要將 css 包裝在<style type="text/css">...</style>標簽中。
這應該<head>...</head>在您頁面上的標記中:
<head>
<!-- title and other things go here -->
<style type="text/css">
.black {
background-color: black;
font-size: 20px;
}
</style>
</head>
uj5u.com熱心網友回復:
您應該通過添加margin:0和洗掉所有填充和邊距padding:0。像這樣:
body {
padding: 0;
margin: 0;
}
這將洗掉所有填充和邊距,以便完全覆寫背景。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/388442.html
