Unable to add bgimage in CSS - css

The below is my piece of code, I am not able to add background-image in my web page, can anyone tell me where I am going wrong?
enter image description here

Create folder called 'images' near your class_id.html file are located and Copy "Aravind_Signature.jpg" image to the newly created image folder
and then change the css background-image property as below
background-image:url("images/Aravind_Signature.jpg");
Note : its bad approach for referring image files path starting from drive names like "c:\". Because when you share your code you need change image path always.

There is nothing wrong, you just need to look at referring to path this way...
either use '/' or '\' so that you will get the right path.

Related

Can't set png image through css content property in Symfony project

My png image is located in src/AppBundle/Resources/public/img
I am trying to set png image through css content property:
content: url(../../public/assets/img/optional-checked.png);
But I am getting
GET http://127.0.0.1:8080/public/assets/img/optional-checked.png 404 (Not Found)
How can I set png image through CSS content property in Symfony project?
First suggestion, That's because you need to respect the hierarchy from where you call your CSS not your script.
Another suggestion would be not to use public folder to upload your assets, instead of this, use web folder (in the root), because if you do like I'm saying then the twig views can use properly asset keyword right.
And the last tip, is that you are trying to read your image from public/assets/img/optional-checked.png when you said that your image is really located in public/img.
Hope this helps.

why I cannot change my background for a div

This is my coding, I want to change my background-image, but it seems not working.
I have tried this coding, it is not working, i don't know what's wrong.
<header style="background-image:url('C:/Documents and Settings/Administrator/desktop/images/navigationBackground.jpg')"></header>
Because you are using full path of file instead of URL.
Change url to http://localhost/images/navigationBackground.jpg, or better without server name, just relative url images/navigationBackground.jpg (and move image to web accessable location instead of desktop)
you have to specify the url of the image, instead of the filesystem path
You should restructure your webpage path. You can put all your resources in a single folder and just specify the url of your image, instead of using filesystem path.

convert a jpeg into url for css

I am new to web design and I think I need to convert a jpeg into a url. I have an image saved locally on my computer. An example website that I am using as a reference has a one page for their html/source code and a different page for their css. All of the images are listed under the css page, however, they are typed in as a url. For example url(..green sea.jpeg) When I try to replace their css code with my image, it can't be found. I know I'm new, so I figure I must be making a simple simple mistake, but everytime I try and look it up online, I find directions on how to convert a jpeg into a url and it looks like you need another kind of software to do this, but I'm not exactly sure. Any help/direction would be very much appreciated!
Thanks!
When you replace your image name for the one you see in the CSS:
url(..green sea.jpeg)
...make sure that the image you are wanting to use is in the same location (folder / place) as the green sea image.
So if I want to replace it:
url(..myNewimage.jpeg)
I would make sure it was in the same place as the image I'm replacing it with.
ALSO, I just noticed that your path is wrong. You have ".." when it should probably be "../".
So try this:
url(../green sea.jpeg)
The url you need for your code is just wherever you have posted the image on your server in relationship to the css file. For example, if your directory is structured like this:
/CSS
-style.css
/JS
/images
-green-sea.jpg
index.html
Then your url would be (../images/green-sea.jpg)

fix file path according to iis

i have a website #local and lots of images in site, but after I deploy site to server images paths are broken(exception given in css file), and I need to fix this as soon as possible.
sample path:
imageurl = #"/Images/sample.gif";
how can i fix this?
thank you.
you can set a appsetting in web.config file with server url like
and get this path on code and add image name with it.
Images (like background-url) in CSS are always referenced relative to the css file.
you need to set in css file like...
background-image: url( '../../Images/image.gif' );
.. this will bring out one folder from current folder hierarchy

Changing image "source" dynamically in runtime

i am trying to modify during runtime an image in my application, this image is located inside assets folder, so thats why i dissable -use-network=false flag, then i call something like this:
img.source="../assets/pict.png";
but it's not working.
i know its a silly question but i am stuck here. any hint i appreciate.
Br
I don't think you need the ".." all of my images are in my "img" folder and I call them with "/img/image.png"

Resources