简体   繁体   中英

Background-image in body?

I am tasked with adding a background image for a home page. However, I do not have access to the CSS file associated with the HTML document I am working on (3rd party company created / has that file). The document I am working with consists of the HTML code's body.

Is it possible to add a background-image within the body of an HTML document? (All the examples I have seen add it in the head)

 <body style="background-image: url(#);"> 

这应该为您解决问题!

There many ways to do this, but I wouldn't suggest this because it's not the professional way! Any way this is an example:

 <body style="background-image: url(https://cdn.pixabay.com/photo/2016/04/15/04/02/water-1330252__340.jpg)"> <p>Content</p> 

  <body background="image.png">

通过在主体中添加图像路径,您可以添加图像而无需访问CSS

There are some ways you could tackle this.

Inline Styles on the body element

<body style="background-image: url(image.jpg);">

Style Block

It's not the nicest technique but you could add this to your HTML

<style>body {background: url(image.jpg);}</style>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM