当前位置:网站首页>Background fixing effect
Background fixing effect
2022-06-12 08:40:00 【Little boy who likes hot pot】
1.background-attachment Property to set whether the background image is fixed or scrolling with the rest of the page
(1)background-attachment:scroll The background image is scrolling with the object content
(2)background-attachment:fixed The background image is fixed
2. The background image scrolls with the content of the object
Code :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> The background is fixed </title>
<style>
body{
background-image: url(images/bg.jpg);
background-repeat: no-repeat;
background-position: center top;
color: #fff;
font-size: 20px;
}
</style>
</head>
<body>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
</body>
</html>Running effect : Content and picture move at the same time

3. Fixed background image
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> The background is fixed </title>
<style>
body{
background-image: url(images/bg.jpg);
background-repeat: no-repeat;
background-position: center top;
/* Fix the background picture */
background-attachment: fixed;
color: #fff;
font-size: 20px;
}
</style>
</head>
<body>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
<p> The background is fixed </p>
</body>
</html>Running effect : Only the content is moving , Background picture does not move

边栏推荐
- Handling abnormal data
- Calling stored procedures in mysql, definition of variables,
- Triggers in MySQL
- Arrays in JS
- When converting tensor to ndarray in tensorflow, the run or Eval function is constantly called in the loop, and the code runs more and more slowly!
- Error: clear the history in the search box in the website?
- Hands on deep learning -- weight decay and code implementation
- What is the difference between ERP production management and MES management system?
- Shell基本语法--算数运算
- JVM learning notes: garbage collection mechanism
猜你喜欢

Loading font component loading effect

Hands on deep learning 18 -- model selection + over fitting and under fitting and code implementation

Hypergeometric cumulative distribution test overlap

安科瑞电动机保护器具有过载反时限、过载定时限、接地、起动超时、漏电、欠载、断相、堵转等功能

余压监控系统保证火灾发生时消防疏散通道的通畅,为大型高层建筑的安全运行和人民生命财产安全保驾护航

【指針進階三】實現C語言快排函數qsort&回調函數

Regular expressions in JS

The difference between deep copy and shallow copy

Hands on learning and deep learning -- simple implementation of softmax regression

Adjust SVG width and height
随机推荐
Principle and configuration of MPLS
(P14) use of the override keyword
Audio and video related links
Lock mechanism in MySQL
Hands on deep learning -- activation function and code implementation of multi-layer perceptron
Hands on deep learning -- Introduction to linear regression model
js实现页面加载后再刷新一次
svg中viewbox图解分析
了结非对称密钥
Hands on learning and deep learning -- simple implementation of linear regression
Centso8 installing mysql8.0 (Part 2)
ASP. Net project development practice introduction_ Item VI_ Error report (summary of difficult problems when writing the project)
ctfshow web4
Vision transformer | arXiv 2205 - TRT vit vision transformer for tensorrt
Website colab and kaggle
JVM学习笔记:三 本地方法接口、执行引擎
What kind of sparks will be generated when the remote sensing satellite meets the Beidou navigation satellite?
What is the difference between ERP production management and MES management system?
网站Colab与Kaggle
You have an error in your SQL syntax; use near ‘and title=‘xxx‘‘ at line 5