Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize fixed background Image with css

Shulou Source: shulou.com Published: 2022-06-01 07:37:12 10月02日 Update

This article will explain in detail how to achieve a fixed background image on css. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

The code is as follows:

Body {

Background-image:url ("/ test/img/154e.png")

Background-repeat:no-repeat

Background-attachment:fixed

}

Here is a line of text: merry Christmas!

Here is a line of text: merry Christmas!

Here is a line of text: merry Christmas!

Here is a line of text: merry Christmas!

Here is a line of text: merry Christmas!

Here is a line of text: merry Christmas!

The effect is as follows:

Background related attributes:

The background-attachment property sets whether the background image is fixed or scrolled along with the rest of the page. A value of fixed indicates that the background image does not move as the rest of the page scrolls.

The background-repeat property sets whether and how the background image is repeated.

This is the end of this article on "how to achieve a fixed background image in css". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Happy one line text image background attributes articles more parts pages good practical code content effects articles knowledge references help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Apple OPPO Reno Shulou Information Docker