如何使用 CSS 为网页添加背景图片
<style>
body {
background-color: #f7f7f7;
}
a:hover {
text-decoration: none;
}
#entry-button-group {
margin-top: 200px;
}
#entry-button-group .btn {
height: 160px;
font-size: 50px;
line-height: 50px;
}
</style>
<p>可以使用以下 CSS 样式来为页面添加背景图片:</p>
<pre><code class="language-css">body {
background-image: url('path/to/image.jpg');
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
}
</code></pre>
<p>其中,'path/to/image.jpg' 需要替换为实际的图片路径。<code>background-size</code> 用于设置图片的大小,<code>cover</code> 表示让图片尽可能地占满整个背景区域。<code>background-repeat</code> 用于设置图片是否重复显示,<code>no-repeat</code> 表示不重复显示。<code>background-position</code> 用于设置图片的位置,<code>center center</code> 表示居中显示。</p>
原文地址: https://www.cveoy.top/t/topic/oAuv 著作权归作者所有。请勿转载和采集!