使用 CSS 将背景图像设置为固定
cssweb developmentfront end technology更新于 2025/6/5 23:08:17
使用 background-attachment属性将背景图像显示为固定。
示例
您可以尝试运行以下代码来实现 background-attachment属性 −
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url("https://www.cainiaomax.com/videotutorials/images/tutor_connect_home.jpg");
background-repeat: no-repeat;
background-attachment: fixed;
background-position: right top;
}
</style>
</head>
<body>
<h1>Background Image</h1>
</body>
</html>
相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

