Background image not working after deployment [closed] - css

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
i have the following issue : background image was perfectly working, then after deployment it's not, the image is in a folder in the public folder here is my code :
react component :
function Header() {
return (
<div className="bannerContainer">
<div className="banner">
<h1>news reader</h1>
</div>
<h3>USER GUID</h3>
</div>
)
}
css styling :
.banner {
height: 20vh;
width: 100%;
background-image: url('/images/banner1.png');
background-position: center;
background-size: cover;
background-repeat: no-repeat;
}

'/images/banner1.png' is an absolute path. It will start at whatever is considered to be the root. This can be different for your local environment and deployed environment.
It's best practice to use relative paths, so that it is not dependent on where the root starts:
background-image: url('../relative/path/to/banner1.png'); /* example 1 */
background-image: url('./also/relative/path/to/banner1.png'); /* example 2 */
EDIT: To test whether the problem is with your url, replace your path with a regular image link we know works. Something like:
background-image: url("https://homepages.cae.wisc.edu/~ece533/images/airplane.png");
If the image does appear in the background, then the problem is definitely with your image path.
In that case I'd recommend playing around with it. Place the image in the same folder as the CSS file trying to access it, and see if you can get any success there before moving the image further away.

Related

Gantry Framework-Joomla How to edit logo from CSS

I would like to know how can I edit CSS files(ex:Logo size, Logo path)
I am using Grantry v4.1.24 and Joomla 3.3.1
See the example of how to change Logo;
#rt-logo {
background: url("/qatarclean/joomla_gantry/images/logo.png") no-repeat scroll 50% 0 transparent !important;
}
#rt-logo {
height: 140px;
width: 267px;
}
How can I find the CSS location for this and how to edit this?
in Firebug it is only showing the only the folder path.
I have created gantry-custom.css file and inserted above data. It doesn't work.
See the attached picture;
Also I want to know how to remove some lines from selected CSS file;
Thanks in Advance,
Sameera Silva
The Gantry Framework uses compiled LESS files. Rather than editing these directly, it is recommended (as you have done) that a custom CSS or custom LESS file is created so that your changes are not overwritten by a template update.
The use of !important might be the reason your override is not working.
You can get around this using CSS specificity as explained by Henning on the RocketTheme Forums at: http://www.rockettheme.com/forum/configuration-and-security/209832-want-nail-how-2use-template-name-custom-css-file-correctly#1028846
For more information on CSS specificity Henning recommends: http://www.smashingmagazine.com/2007/07/27/css-specificity-things-you-should-know
In this particular case, the following should fix the issue you are having:
div#rt-logo {
background: url("/qatarclean/joomla-gantry/images/logodf.png") no-repeat scroll 50% 0 transparent !important;
}

Background-image not displaying online

Arg, it's getting frustrating!
None of the solutions on Stack Overflow are working for me, and I just don't know why my background-image isn't showing!
I gave it a background-color, and it worked fine. Offline you can see the background-image, but when I upload my site it's gone. When I type the path of my image, it shows. So it's there.
This is the site:
http://stilld.nl/2014/
In the dark blue area should be my logo.
#fade-it{
background: url('../images/branding.png');
margin-left: auto;
margin-right: auto;
display: block;
width: 408px;
height: 500px;
opacity: 1;
position: relative;
overflow: hidden;
z-index: 2000;
}
I've tried a ridiculous high z-index, still nothing. I tried opacity: 1. Nothing. I tried display: block. Nothing. I checked the path a thousand times. I used background: and background-image:. Still nothing.
Hope you guys can help me out!!
The file branding.png does not exist on your live server. Check it's location and make sure that:
The file is in the right place;
The CSS is referring to it correctly.
For reference, the way your CSS is currently set-up, it attempting to load this image from: http://stilld.nl/2014/images/branding.png. Try clicking the link, you'll see it returns a 404 'not found' error page.
I think the path that you have provided is not matching on deployed site.
Try giving image path as
background: url('./images/branding.png');
instead of
background: url('../images/branding.png');
may be this will work
You should make sure that the image is in the right folder, relative to the URL you're using.
../images/image.jpg means "go up one folder, find a folder named "images" and use the image called "image.jpg" inside."
./images/image.jpg means "find a folder called "images" in this current folder and use the image called "image.jpg".
/images/image.jpg means go to the root folder, find folder "images" and use "image.jpg".
EDIT: Found it.
Your image is in /2014/images/. Right now you're trying to make it find the images folder inside the 2014 folder. What you can do is set the path to:
/2014/images/branding.png

Change a Page's Header Image in WordPress [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I am using Sunrise Theme from s5themes.com , and I was wondering if in the individual pages I can have a different Header Image, because from what I can tell they use the same CSS code in displaying the header image on the Home Page.
Here is the screenshot of the Home page showing the Image as header
And here is the screenshot of the a Page (About Us) which uses the same Image (the brown texture with green part) as header only seemed zoomed-in.
I tried digging into the code and I believe this is the part in the Styles.css that deals with it.
CSS
.header-wrapper {
background: #333;
background-image: url(img/wood-only.png);
background-attachment: fixed;
background-size: cover;
min-height: 200px;
So I edited the code above, unfortunately it also affects the Image in the Home page
I tried setting the background-size into
background-size: auto;
Ideally I can work with editing the template files but I am not familiar with WordPress' structure, and now I am not sure how to procede.
In WordPress, the header is defined by default in "header.php". You need ftp access, and copy header.php, rename it header2.php, make your changes, save. Then copy whatever your main page template is, and replace the with and save that as a different file, such as main2. Make sure to change the name in the commented area at the top so WordPress will show a distinct name for that template. Upload your new pages to your theme directory. On the pages which you want to have the changed header, select your new page template and save.
Walk in the park.
I managed to solve this without relying too much on creating new templates, by using JetPack plugin.
And took advantage of it's ability to add Custom CSS
This is the CSS line I added
body.page .header-wrapper {
background: #333;
background-image: url(http://image-url/image.png);
background-attachment: fixed;
background-size: auto !important;
min-height: 200px;
}

CSS displaying only selective images?

I'm having a problem with my css and it's really winding me up. basically i have a 'background-image: url' set in my styles sheet and for some reason it won't display my file 'form_bg.png' but having just pasted a photo in the directory '1.png' this shows up. No matter what i try, whether i rename the file or anything like that 'form_bg.png' will not show?
Obviously the directory path is correct as it's pointing to '1.png' just not other files.
Can anyone let me know why this would happen?
Thanks
#main form {
width: 440px;
height: 450px;
background-image: url(assets/img/form/icons.png) no-repeat;
padding-top: 50px;
}
using no-repeat in background-image is not correct. to use them in one line, use 'background' like this:
background: url('xyz.png') no-repeat;
and about your problem, try with absolute path of your image like this:
background: url('http://www.google.com/images/srpr/logo3w.png');
I think that image is not a original png format that is maybe file extension only renamed so that the image is not shown to check this open that image in photoshop, if it is extension changed it will not opened.

Localize images via css

The site I work on has a lot of images that contain text. This includes buttons and navigation.
To support localization I include 2 css-files. One that has non language specific properties (font, colour ...) and one that has language specific properties. There is only 1 language specific file served to the user depending on his choosen language.
The language specific file (/content/en/Site.css , /content/de/Site.css ..) has information about background images
div.topHeader p#searchHeader
{
background: url(/images/de/headers/search_lo.gif) no-repeat scroll center center;
}
This works smoothly but I will have a lot of duplicate code. In english the css will be:
div.topHeader p#searchHeader
{
background: url(/images/en/headers/search_lo.gif) no-repeat scroll center center;
}
I will have a couple of languages thats why it would realy pay out to optimize this. Is there a better way to do this?
Just extract out only language specific part from the main CSS to a new CSS for each language and include that CSS in your page dynamically. In this way do don't have to manage lots of CSS classes.
You can try consolidating all external graphics references in separate CSS and referencing it separately in your code.
If you mean form paths in your CSS dynamically, well, you could write a handler to process this particular request for your CSS, read it on the server-side from the file, replacing all language marker parts as required (document.Replace("{lang}", "de")) and then serve the modified CSS back. But it would require some work.
Rather than having different CSS files for each language you could one file, site.css.aspx or similar and process the file, output the paths based on the language supplied POST/GET variables or in the accept headers.
See similar question here
For a start you could use background-image instead of background to save repeating the repeat, positioning, scrolling and colour information.
To really optimise it I would simply dynamically serve the css based on the user's localisation. eg: through a php script or something. You could just do something like background-image: url(/images/<?=$lang ?>/headers/search_lo.gif).
not sure but u can have something like this ,
div.topHeader p#searchHeader {
background: url(/images/headers/search_lo__en.gif) no-repeat scroll center center; }
div.topHeader p#searchHeader {
background: url(/images/headers/search_lo__de.gif) no-repeat scroll center center; }
where last word after __(dauble underscore) will added dynamically
as
div.topHeader p#searchHeader {
background: url(/images/headers/search_lo__{%lang%}.gif) no-repeat scroll center center; }
An easy solution would be to apply a class or ID to the body tag in the HTML based on their locale. Then in the stylesheet you could do something like:
div.topHeader p#searchHeader
{
background: no-repeat scroll center center;
}
body.en div.topHeader p#searchHeader
{
background-image: url(/images/en/headers/search_lo.gif);
}
body.de div.topHeader p#searchHeader
{
background-image: url(/images/de/headers/search_lo.gif);
}
There's still going to be a bit of duplication, but you've reduced the amount of CSS you have to write for each localisation.
You can create dynamic CSS with PHP or similar. Here's a PHP example:
index.html:
<link rel="stylesheet" type="text/css" media="screen" href="style.php">
style.php:
<?php
header("Content-type: text/css");
$lang = $_SESSION['however_you_are_detecting_lang'];
?>
body {
background-image:url(images/<?=$lang?>/image.png);
}
that will fetch images/en/image.png or images/de/image.png

Resources