#hero {
background: url('/wp-content/themes/bootstrap2wordpress/assets/img/hero-bg.jpg') 50% 0 repeat
}
Here is my code but still doesn't work
Without more information (some HTML to go with it) or a webpage you are having trouble with, it is very hard to understand what you are trying to accomplish.
I would try something like this, as it sounds like you are trying to have the background image repeat.
hero {
background: url('/wp-content/themes/bootstrap2wordpress/assets/img/hero-bg.jpg') repeat;
}
https://www.w3schools.com/cssref/css3_pr_background.asp
Try this, But you need to add this to your header.php or any PHP file header section. This will not work in CSS file.For more details visit URL
<style>
.hero {
background-image: url("<?php echo content_url(); ?>/wp-content/themes/bootstrap2wordpress/assets/img/hero-bg.jpg") 50% 0 repeat;
}
</style>
Hope this will help you.
Just navigate up a directory or two using ../
hero {
background: url('../../img/hero-bg.jpg') repeat;
}
I am assuming hero is your class name thats why prefixed with .
In your code I could not find . , so check the same one more time.This also can be one issue if it is not there in your code.
Can you try this way:
.hero {
background: url('/wp-content/themes/bootstrap2wordpress/assets/img/hero-bg.jpg');
background-size: 50% 0;
background-repeat: repeat;
}
Related
How to apply background image from local drive instead of internet. Where is the mistake?
I have tried this way, it is success. (URL from Internet)
body.my-login-page {
background: url(https://hdwallsource.com/img/2014/9/green-gradient-wallpaper-26051-26736-hd-wallpapers.jpg) #277214 no-repeat;
}
But this method is unsuccessful. (path from Local)
body.my-login-page {
/* background-color: #6aaaeb; */
background: url(/images/green_wallpaper.jpg) #277214 no-repeat;
}
My answer, just apply as david said above with double dot ".."
body.my-login-page {
background: url(../images/green_wallpaper.jpg) #277214 no-repeat;
}
It should work if you use a full file path, or add a "..".
Full File Path Example: C:\Users\Photos\image.png
".." Example: ../Photos/image.png
Comment on this post if that does not work, but in the past, that has worked for me. Also, I would suggest using <img src="/images/file.png"></img>, since in my experience it has better compatibility.
Here is a fixed version of your example, using both of the methods I stated:
".." Example:
body.my-login-page {
background: url(../images/green_wallpaper.jpg) #277214 no-repeat;
}
Full File Path Example:
body.my-login-page {
background: url(C:/<INSERT PATH>/images/green_wallpaper.jpg) #277214 no-repeat;
}
I have an image in the assets/images and I want to set it as a background on the main page refers to a given class, but I do not see image in production Heroku
application.scss
.has-bg-img { background: url('img.PNG'); center center; background-size:cover; }
In my Rails app, I change the filename to end with .scss.erb and then have the following as an example. A comment at the top, followed by the example.
//= depend_on_asset "sprite-article-r4.svg"
.contents {
background-image:url('<%= asset_path("sprite-article-r5.svg") %>');
}
Reference this SO question
you must set a full path like url('localhost/apps/assets/images/myimg.jpg')
If your assets are not static and committed into your repo, and you're trying to reference a dynamically uploaded image, you might have to read on how to work around with Heroku's ephemeral filesystem
You can try image-url or asset-url helpers.
Asset Pipeline
Edit :
actually, i'm not sure about your syntax
.has-bg-img {
background-image: url('img.PNG');
background-position: center center;
background-size:cover;
}
it should work better.
In Rails, you have to prepend directory name to url. For your case change
.has-bg-img { background: url('img.PNG'); center center; background-size:cover; }
to
.has-bg-img { background: image-url('img.PNG'); center center; background-size:cover; }
This is because you are storing your image in images(assets/images) directory.
Try to the following
.has-bg-img {
background-image: asset-url('img.png');
background-size: cover;
}
This should work, I don't why you use center center; I think that is syntactically invalid see this Horizontal & Vertical Align
I'm creating a custom style for Facebook with the Firefox plugin Stylish. I'm trying to get the top blue bar flat, but I cannot. I use the CSS code:
#blueBar {
background-color: transparent !important;
}
But it has no affect on it. Why is this?
#BrockAdams - I tried that, still nothing so I just used:
#blueBar {
background-image: url("http://i.imgur.com/vUnrU8x.png") !important;
}
Try to use change id #blueBarHolder background. like:
.hasSmurfbar #blueBarHolder, .hasSmurfbar #blueBarHolder.slim,
.hasSmurfbar #blueBarHolder #pageHead,
.hasSmurfbar #blueBarHolder #headNav,
.hasSmurfbar #blueBarHolder #blueBar {
background: transparent !important;
}
Hope it will works.
background image isn't showing up I have in main.css
body {
background-image: url('/../img/background.jpg');
}
my file paths are
C:/pathTo/css/main.css and
C:/pathTo/img/background.jpg
thanks for any help
Joel
body {
background-image: url('../img/background.jpg');
}
Hope this helped!
Try without the first backslash.
body {
background-image: url('../img/background.jpg');
}
I'm in the midst of creating a SASS mixin that will let me take a spritesheet of social media icons and display them, but I'm having an issue with the background-position when it's hovered over, here's the SASS code:
#mixin social-button($imgurl,$xpos,$ypos,$height,$width) {
background-image: url($imgurl);
background-position: $xpos $ypos;
display: block;
float: left;
height: $height;
width: $width;
&:hover {
background-position: 0px -$height;
}
& span {
position: absolute;
top: -999em;
}
}
And my include:
a.facebook {
#include social-button("../img/social-buttons.png",0px,0px,26px,26px);
}
If you'd like to see/use the spritesheet in action, I've uploaded it here: http://i49.tinypic.com/2evtbwp.png
Here's the HTML as well:
<a class="facebook" href="#"><span>Facebook</span></a>
Essentially the CSS output for the hover is displaying as this:
a.facebook:hover {
background-position: -26px;
}
And in Firebug it displays as this:
a.facebook:hover {
background-position: -26px center;
}
Any help is greatly appreciated, I'm pretty stumped on what I'm doing wrong at this point.. thanks!
PS. I'm going to be creating 5 of these, so I wouldn't mind creating a loop that could auto generate that for me, but at the present time it's not a huge deal, just need to get the hovers working first!
You have to add parentheses around variables when you change them to negatives otherwise it just does the math (0px - $height):
background-position: 0px (-$height);
You probably want to fix the 0px, too.