user image

Mohamed Aboelfotoh
Published in : 2022-02-13

Can't move the background-image code from CSS file to HTML file.

HTML & CSS

Basically, I'd want to change the background image code from the.css file to the.html page. The image does not appear on my website when I do this.

The picture (photo.png) is successfully shown and I use the following code.

<div >
.select-resource { margin-bottom:5px; background-position: 400px -5px;}

But, I need to use the next code, but still the picture does not appear when I do so. The code is as follows:

<div >
.select-resource { margin-bottom:5px;background-position: 400px -5px;}

Is there anyone who can guide me with this? 

Comments

Joseph Morgan Date : 2022-02-13

Best answers

11

Best answers

11

This must be because the URL is missing, when you use url() in CSS file it uses the location from the CSS file & when you move it to HTML it should be different because both HTML & CSS are not in the same Folder

Mahmoud Santos Date : 2022-02-21

Best answers

2

Best answers

2

try to add single quotes like :

background-image: url('path');

 

<div >

 

hope it worked

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

Searching for a better way to use abstracts in Dart SASS
Publish date: 2022-02-10 | Comments: 0

Tag: HTML & CSS

Flex Box last column break to the next row
Publish date: 2022-02-10 | Comments: 1

Tag: HTML & CSS

Multiple classes in :not() function in CSS
Publish date: 2022-07-25 | Comments: 2

Tag: HTML & CSS

Sticky header goes behind the Images
Publish date: 2022-02-10 | Comments: 1

Tag: HTML & CSS

Logo shrinks when resizing the browser
Publish date: 2022-02-10 | Comments: 2

Tag: HTML & CSS

How to horizontally align to the centre a li inside an ul?
Publish date: 2022-03-04 | Comments: 2

Tag: HTML & CSS

How can I add engraved style to my buttons using CSS?
Publish date: 2022-03-01 | Comments: 5

Tag: HTML & CSS

What is the need for using (for) attr in the label of an input tag?
Publish date: 2022-02-11 | Comments: 2

Tag: HTML & CSS