<!DOCTYPE html>
<html>
<head>
<title>HTML 添加背景图片示例</title>
<style>
/* 使用 CSS 设置 body 的背景图片 */
body {
background-image: url('https://example.com/image.jpg'); /* 设置背景图片的 URL */
background-size: cover; /* 使背景图片覆盖整个页面 */
background-repeat: no-repeat; /* 禁止背景图片重复 */
background-position: center; /* 将背景图片居中显示 */
}
</style>
</head>
<body>
<h1>这是一个带有背景图片的页面</h1>
<p>你可以看到这个页面有一个背景图片。</p>
</body>
</html>
background-image: url('https://example.com/image.jpg');
:设置背景图片的 URL。请将 'https://example.com/image.jpg'
替换为你想要使用的图片的实际路径。background-size: cover;
:确保背景图片覆盖整个页面,而不会被拉伸或裁剪。background-repeat: no-repeat;
:禁止背景图片重复显示。background-position: center;
:将背景图片居中显示。如果你有任何其他问题,请随时告诉我!
上一篇:html图片怎么导入
下一篇:html左对齐
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站