Home  >  Article  >  Web Front-end  >  How to write code to change or add website background image in HTML? (example)

How to write code to change or add website background image in HTML? (example)

藏色散人
藏色散人Original
2018-08-06 16:19:0716872browse

This article mainly introduces how to change or add website background images in HTML code? For novices, the easiest way is to change the background image.
We can right-click on the web page to view the website source code, then find the background image code in the css, view the background image path, and replace the image through ftp or the server. The specific code examples for changing or adding website background images in

html are as follows:

/*控制背景图片是否滚动*/
body{background-image:url(图片地址);background-repeat:no-repeat;background-attachment:fixed;} 
body{background-image:url(图片地址);background-repeat:no-repeat;background-attachment:scroll;}

How to write code to change or add website background image in HTML? (example)

Note:

background The -attachment attribute sets whether the background image is fixed or scrolls with the rest of the page.

Possible values:

scroll: Default value. The background image moves as the rest of the page scrolls.

fixed: The background image does not move when the rest of the page scrolls.

inherit: Specifies that the setting of the background-attachment attribute should be inherited from the parent element.

I hope this article introduction will be helpful to everyone.

【Recommended related articles】

HTML Realizing the replacement of background images

How to set the DIV background image background

Using CSS to set the background image for an image

How to use the css selector to switch the background image of the navigation bar?


The above is the detailed content of How to write code to change or add website background image in HTML? (example). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn