使用 CSS 将背景图像设置为固定
使用 background-attachment 属性将背景图像显示为固定。
示例
你可以尝试运行下面的代码来实现 background-attachment 属性 −
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url("https://tutorialspoint.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>
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP