I have a CSS background sprite (2x size) that's showing up inconsistently on Chrome only. When I load the page, what is supposed to be a series of flags looks like this :
Now, if I use safari or firefox, it loads correctly
How do I fix this strange issue?
.flag {
background: url("flags_2x.png") no-repeat;
display:inline-block;
background-size:18px 7800px;
width:18px;
height:18px;
}
.flag-abkhazia-12 {
width: 12px;
height: 12px;
background-position: 0 0;
}
Nobel Prize to anyone who can figure out what's causing this.
Firefox:
Internet Explorer:
Chrome:
As you may be able to see, in the Chrome one there is a gap between the Facebook icon and LinkedIn icon, while in the other browsers they look evenly spaced.
My CSS is
#social-icons-holder { text-align: right; }
#social-icons-holder > a { height: 20px; padding: 5px 10px; margin-left: 5px;}
#social-icons-holder > a:before { content: ""; }
.fb-icon { background: url(assets/Footer_FB.png) no-repeat; }
.fb-icon:hover { background-image: url(assets/Footer_FB_Hover.png); }
.li-icon { background: url(assets/Footer_LinkedIn.png) no-repeat; }
.li-icon:hover { background-image: url(assets/Footer_LinkedIn_Hover.png); }
.twitter-icon { background: url(assets/Footer_Twitter.png) no-repeat; }
.twitter-icon:hover { background-image: url(assets/Footer_Twitter_Hover.png); }
and I've verified that the images are all of the same size and have the same dimensions for the white square portions of the image.
EDIT: Strange ... just tried a fiddle http://jsfiddle.net/4dgcnc0q/1/ and it looks fine in Chrome. Also, the images are smaller on Chrome on my webpage than they are on IE, FF and on the fiddle in Chrome.
I have some problem with this (not exactly this). Well, I thing that chrome and other browsers have some Preinstalled setting, that is not same in all browsers. That might be the problem. Try: open chrome > inspect element > and find ALL styling for your images. There should be some css, that browser made. Try to change them...
I will like to get help please with an issue I got in both IE11 and Opera with CSS SVG sprite.
For some reason both of these browsers are showing the SVG in a very wrong way and some times even not at all.
Here's my code which works great on Chrome, Safari and Firefox:
.item {
width: 50px;
height: 50px;
float: left;
margin-right: 40px;
background: #eee url('1.svg') no-repeat 0 0;
}
.item.i1 {
background-position: 5% 40%;
background-size: 440%;
}
.item.i2 {
background-position: 43.3% 40%;
background-size: 417%;
}
.item.i3 {
background-position: 82.6% 40%;
background-size: 404%;
}
A live jsfiddle demo: http://jsfiddle.net/DBH29/
Am I missing something? if not and my code is fine, and there's no way to fix it, then how can I make a CSS fallback to an image (PNG) or how to detect it with Modernizr please?
possible related to: SVG in Opera using CSS background-image with scaling , in short to work with Opera 12:
"Removing the width and height attributes in the svg"
this is the site: www.luckybabynames.in
This site background is perfectly coming in both firefox and internet explorer. But the problem is now with google chrome.
Here is the css for the body background
body {
background: url("images/img01.gif") repeat-x scroll 0 0 #FFFFFF;
color: #333333;
font-family: Georgia,"Times New Roman",Times,serif;
font-size: 12px;
text-align: justify; }
no inline style written in body Tag
But in google chrome after the page fully loads it writing itself some inline style in the body tag.
<body style="postion: absolute; width: 1583px; height: 449px; background-position-x: 0px; background-position-y: 34px !important; " class="backgroundPositionTuned">
But actually there is no style and even the class="backgroundPostionTuned"!
How to solve this?
This previous question suggests that this behavior may be caused by the uTorrentControl extension:
Chrome changing background image position
I've used the following code for background image of body tag.
background-image: url(images/taling.gif);
background-repeat:repeat-x;
background-color: #2E2E2E;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
it works in IE,Opera and chrome but doesn't work in FireFox.
I've tried also :
background-image: url("images/taling.gif");
and
background-image: url('images/taling.gif');
but it doesnt work on FireFox
your document body is height=0, and width=0, if you try to give it some height or width the image should be displayed
There is no problem with your CSS. What the problem is most likely the result of is either you are not assigning a width and height to the body tag, you are naming your image incorrectly, using the incorrect extension for your image, or the path to your image is incorrect, but there is also a possibility that you need to add a width and height.
If you use Firefox, you can test what is going on by using Firebug. You right click, and choose inspect element. Once done, in the right column of Firebug, you can see your declaration for background-image. If it says image not loaded or cannot be found, then one of the three things I pointed out above is the problem.
I know you said that the image does show up in other browsers, just not in Firefox. So, consider some modifications to the rest of your CSS. You may not be specifying a browser reset.
Just FYI, you can condense your CSS by doing the following:
background-image: url(images/taling.gif);
background-repeat:repeat-x;
background-color: #2E2E2E;
to
background: #2e2e2e url(images/taling.gif) repeat-x;
As for the body tag, you may want to add these properties and values:
margin: 0;
padding: 0;
width: 100%;
height: 100%;
Google "CSS browser reset"
One example of a browser reset is the following:
html, body {
width: 100%;
height: 100%;
}
body {
margin: 0;
padding: 0;
}
The above is the most simple browser reset you can have. It does not take into account ul,ol,li,h1,h2,h3,h4,h5,h6,li,p,a,img,blockquote, etc.
Also, look into using a clearfix.
I could ramble on and on as to why you may be having this problem.
I hope that helps.
Try:
background: url('yourimage.ext') repeat-x;
It works for me.
Edit: to match what you're doing, it should in fact be:
background: #2E2E2E url('images/taling.gif') repeat-x;