Is it possible for css to change background image depending on which site we are?
For example, when I am on a index.php, I want to see images/index.png, and when I am on first.php I want to have /images/image.png.
You can change the background by leaving it blank on css.
<style>
body
{
background-image: url(/images/index.png);
}
</style>
And use that on every webpage.
Related
I have an SVG background image embedded in a CSS file as a data url:
.what { background: url('data: image/svg+xml; utf8, <svg> ... </svg') }
I want another element to have the same background image, only in a different color, but I don't want to repeat the whole SVG code.
<div class="what one">...</div>
<div class="what two">...</div>
So how do I change the color of a background SVG image?
No Javascript, please.
None of the other related questions answered this, because the solutions given there rely on serving two different files, which I want to avoid because I want to minimize file size for mobile users.
Apparently, as Noah Blon explains, it is possible to style the color of an SVG background image using CSS filters.
An example he gives on his site is:
.icon-blue {
-webkit-filter: hue-rotate(220deg) saturate(5);
filter: hue-rotate(220deg) saturate(5);
}
Please visit his site for more information and two other solutions that do not involve changing the color but SVG background sprites and creating an "inverted" SVG that covers the background and is transparent where the background color shines through to create a colored form.
Unfortunately, IE does not support filters.
You can't restyle the contents of a background image with CSS. It doesn't matter if it's an external SVG, or one applied as a Data URI.
Check out this webpage: https://css-tricks.com/using-svg/
Part way down the page is a header called "Now you can control with CSS!"
They appear to be changing the color of the image inline with statements such as
.kiwi {
fill: #94d31b;
}
I have an SVG background image embedded in a CSS file as a data url:
.what { background: url('data: image/svg+xml; utf8, <svg> ... </svg') }
I want another element to have the same background image, only in a different color, but I don't want to repeat the whole SVG code.
<div class="what one">...</div>
<div class="what two">...</div>
So how do I change the color of a background SVG image?
No Javascript, please.
None of the other related questions answered this, because the solutions given there rely on serving two different files, which I want to avoid because I want to minimize file size for mobile users.
Apparently, as Noah Blon explains, it is possible to style the color of an SVG background image using CSS filters.
An example he gives on his site is:
.icon-blue {
-webkit-filter: hue-rotate(220deg) saturate(5);
filter: hue-rotate(220deg) saturate(5);
}
Please visit his site for more information and two other solutions that do not involve changing the color but SVG background sprites and creating an "inverted" SVG that covers the background and is transparent where the background color shines through to create a colored form.
Unfortunately, IE does not support filters.
You can't restyle the contents of a background image with CSS. It doesn't matter if it's an external SVG, or one applied as a Data URI.
Check out this webpage: https://css-tricks.com/using-svg/
Part way down the page is a header called "Now you can control with CSS!"
They appear to be changing the color of the image inline with statements such as
.kiwi {
fill: #94d31b;
}
I've noticed that most of the websites now "somehow" disable viewing some of the images used in their template, so I'd like to obtain this same result:
I thought instead of using the tag <a>with <img>, I put a div and set the "background" property as an image yet it's still viewable in the browser!!
Any ideas?
This is not disabling the images, this is done by using images as backgrounds in CSS and not as a normal img tag like:<img src="your-image.jpg" />. Here's an example how this is done:
HTML
<div class="randomClass"></div>
And the CSS goes like this:
.randomClass {
background-image: url('http://i.ytimg.com/vi/1WmaBpkGjXk/mqdefault.jpg');
background-color: #cccccc;
width:350px;
height: 180px;
}
On the Jsfiddle link I provided above if you right click on the 1st image you have the option to open the image on a new page or the option to download it. On the second one you don't have this options by right clicking on it, but still these images can be downloaded in other ways.
I am trying to change background color of my html page but its not reflecting. I am using jquerymobile, marionette for my pages. In my css i have written
body {
background-color:rgb(44,2,4);
}
even i had tried
html, body {
background-color:rgb(44,2,4);
}
What happens is the background color is being set, but i can see on html page just for a flash when the pages loads but after that the default jquerymobile theme gets set.
Can anyone please help me with the solution?
Thanks in advance.
When working with jQuery Mobile you must change class .ui-page if you want to change background color. Even if you change body background with !important it will still stay hidden because class .ui-page acts as an overlay over whole page.
Even more it must be done with overriding, like this:
.ui-page {
background:rgb(44,2,4) !important;
}
Working example: http://jsfiddle.net/6wD7v/
EDIT :
Found it. You are also using a panel which uses additional overlay div over .ui-page.
This CSS will work now:
.ui-page, .ui-panel-content-wrap {
background:rgb(44,2,4) !important;
}
I have been trying to change the background image of the wordpress theme but i am unable to change it.
I tried:
body {
background : url('images/squad.jpg');
}
I placed this code under design-settings in custom css styles. But i do not see any changes
in wordperss stylesheet file, search for body and html selectors and check if any background applied to them.
in html selector add this property:
backbround: #fff url(imagePath) no-repaet top left;
you can change #fff to the color that is more related to your background image. it's not necessary, but it's best practice.
if your background image is a pattern and you want it to be repeated, change no-repeat to repeat this should work.
Is your css file is in separate folder?
try this
body {background : url('../images/squad.jpg');}