I am attempting to link a css file to a https - css

So my client insists I have to link the logo and images through a CSS sheet, But the site isn't live or uploaded so how will the website see the linked objects like this.
Example:
background: url("https://mysamplesite/assets/image/header/bullet_mobile_subsmenu.png") left center no-repeat;
Logic tells me that it needs to read:
background: url("image/header/bullet_mobile_subsmenu.png") left center no-repeat;
But it isn't a URL, is it? what should it say instead of URL?
I know it sounds novicey... I am a novice, I do what I do and if it isn't broken I do it again and again.
Thanks all.

It is a relative URL, which guides the browser on reaching the file relative to the current location.
If you set it inside a CSS file, make sure the path you mention is relative to the source of the CSS file and not relative to the document (as suggested here).

Related

CSS background-image does not load

I'm currently making a website in PHP. When developing it I use xampp (localhost), and the pictures are visible.
<div data-bs-parallax-bg="true" style="height:500px;background-image:url("assets/img/mypicture.jpg");background-position:center;background-size:cover;">
When I wanted to upload to web server the pictures are invisible.
I tried these options but still not working.
style="height:500px;background-image:url('assets/img/mypicture.jpg');
style="height:500px;background-image:url('./assets/img/mypicture.jpg');
style="height:500px;background-image:url('../assets/img/mypicture.jpg');
style="height:500px;background-image:url('https:/example.com/assets/img/mypicture.jpg');
and the same with only background:url();
Thanks in advance!
Remove the quotes (single, double).
background-image: url(assets/img/mypicture.jpg);
Also, be careful when using relative paths here. Check this question too:
Using relative URL in CSS file, what location is it relative to?

Background image css won't show in asp.net

I'm trying to get the image in my C:\Images directory, I've seen css about background-image: url() but I can't find a directory based css for that or did I use the wrong css type?
Here's my css so far:
body
{
background-image: url('C:\Images\background.jpg');
background-repeat:repeat;
}
Don't use static paths in your CSS or HTML such as 'C:\Images\background.jpg' This makes your site non-portable and easy to break.
Always use relative paths when referencing the other files in the site. The browser knows how to resolve the path and requests the full path based on where the site is located.

Loading background images from css file in meteor

I am building a meteor application for the first time and have run into some issues. In particular, I'm trying to get a picture viewer to work but the right and left arrows in the navigation buttons seem to be missing. When I attempt to load the images that are supposed to be in the button using google's developer tools, it's being displayed as an empty image. Thus, it's probably a case of me not putting the image file in the appropriate directory and as a result meteor is not able to load it in the css file. I'm not sure if this is the case or it's something else. It's probably not any syntax errors as I'm able to see the arrows in the button when I run the plugin outside of meteor.
Here's the line in my css file:
background: transparent url('themes.gif') no-repeat left top; margin-top: -45px;
So I managed to get it to work. I created a resources directory in the public folder and changed the url in the css file to url("/resources/button"), which seemed to do the trick.
You can leave your CSS as it is and put the themes.gif file in the /public directory of your Meteor app -- then it should be accessible.
Per the docs:
Lastly, the Meteor server will serve any files under the public directory, just like in a Rails or Django project. This is the place for images, favicon.ico, robots.txt, and anything else.
You have to prefix a / in front of your file name.
my web site architecture
body{
background-image: url('image/back1.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
}
Files need put to /public directory and remove "/public" in path from css.
For example:
If Image in path - /public/img/logo.png
Then use below CSS :
background-image('img/logo.png');

background-image won't show on site but will in Dreamweaver

I'm having a problem where I have a background image that will show up perfectly fine when I'm using it in dreamweaver, but once I upload my site and the CSS files and everything it won't show.
Here's my CSS code:
.ELSsubbg {
background-image: url('../images/NTG_images.jpg');
background-repeat:no-repeat;
background-position:top left;
}
Any help would be great.
Because you are using a relative path in your CSS, where the stylesheet is looking for the image may be different than where you are seeing it when you go to it directly in the browser.
Try using an absolute path to your images directory instead of a relative one. Assuming you can see the image in your browser at http://www.website-name.com/images/NTG_images.jpg try removing the dots to make the path absolute from the root of your website.
background-image: url('/images/NTG_images.jpg');
Have you uploaded the image? Have you uploaded it to the right place? Is the CSS looking for it where you think it should be?
The easiest way to answer these questions is to use the browser's developer tools (eg Firebug) to watch the network traffic your page generates. Look for the request where it tries to load the graphic. Is it giving a 404 error? Probably.
If you are getting a 404, look at the URL it's calling to find out why. The answer should become clear.

How do I refer to an image resource from CSS in grails?

I want to refer to an image in my main stylesheet for a Grails app and I can't get it to work. My image lives in the standard location in my Grails app...
project\web-app\images\outbound-blue.png
In my stylesheet I want to use it as a background image for a class...
.messageimg {
height:17px;
width:16px;
background-image:url(images/outbound-blue.png);
background-repeat:no-repeat;
}
This doesn't work for some reason. My stylesheet is in the normal location too, i.e.
project\web-app\css\main.css
I get a missing image marker when I load the page in the browser. I have checked that I have no typos in names etc. I have also tried fiddling around with the virtual path in the url, but I can't figure out what I need to put in there to make this work in Grails.
I don't want to use GSP and insert an IMG tag into my code because I want to control the image through styles.
So, what am I doing wrong?
A more portable way to specify image locations is to use the resource() function:
.messageimg {
height:17px;
width:16px;
background-image:url('${resource(dir: "images", file: "outbound-blue.png")}');
background-repeat:no-repeat;
}
Try adding "../" at the beginning of the URI. For example:
../images/outbound-blue.png
The "../" at the start of the URI tells the browser to go up one level to the parent directory then look in the images directory. Currently you have it set up to look for a subdirectory called images in the directory containing stylesheets.
Be aware though. Using $resource{... does not work within a referenced .css file. You need to add a style element.
Typically you would reference a resource in a style sheet as a relative url. The url of your image should be relative to the CSS file's location. So ../images/outbound-blue.png from /appName/css/main.css will be referencing /appName/images/outbound-blue.png
If you are still having issues, You can debug this by using a tool like firebug to inspect the page and verify each step in your style.
Verify that:
The item that you think is being styled is picking up the styles.
The image that you are referencing can be accessed both manually, and via firebug.
The css file that you are loading isn't cached and is actually refreshed by the browser.
So the problem seemed to be that the browser was looking into
http://localhost:8080/<app-name>/assets/images/<background-image-name>
which seems correct but if you inspect other images on the page, they render from the path
http://localhost:8080/<app-name>/assets/background-image-name
So, just by excluding images in your path-name should fix the issue. However, this is just a work around which I am sure would have a better explaination and a solution. Cheers.

Resources