See Demo. Please check on Chrome and firefox and feel the difference
I have a div element that uses the css classes below. Basically, I'm creating a responsive sprite of images:
.what-wwb-logo, .what-national-geographic-logo, .what-atm-logo, .what-us-ski-logo-large, .what-boart-logo,
.what-comas, .what-left-arrow, .what-right-arrow{
max-width: 100%;
background-size: 100%;
background-image: url('/images/sprites/what_our_client_say_new.png');
}
.what-wwb-logo {
background-position: 0 0%;
background-size: 100%;
padding-bottom: 41%;
}
.what-national-geographic-logo {
background-position: 0 16.588419%;
background-size: 118.648019%;
padding-bottom: 59%;
max-width: 77%;
}
.what-atm-logo {
background-position: 0 42.466823%;
background-size: 146.685879%;
padding-bottom: 94%;
max-width: 100%;
}
.what-us-ski-logo-large {
background-position: 0 65.003723%;
background-size: 181.785714%;
padding-bottom: 65%;
max-width: 70%;
}
.what-boart-logo {
background-position: 0 84.194978%;
background-size: 200.393701%;
padding-bottom: 84%;
max-width: 84%;
}
.what-comas {
background-position: 0 92.206077%;
background-size: 435.042735%;
padding-bottom: 62%;
max-width: 80%;
}
.what-left-arrow {
background-position: 0 96.196003%;
background-size: 820.967742%;
padding-bottom: 93%;
min-width: 7px;
}
.what-right-arrow {
background-position: 0 100%;
background-size: 820.967742%;
padding-bottom: 93%;
min-width: 7px;
}
And in my HTML I have the following code:
<div class="what-right-arrow " />
...
<div class="what-left-arrow " />
...
<div class="what-comas" />
...
<div class="what-boart-logo" /> // and so on and all divs in different position
I ran the HTML in Chrome, IE and Firefox. It ran good in Chrome and IE but not in Firefox.
The problem is that images (ONLY what-right-arrow, what-left-arrow and what-comma) are vibrating (up and down, left and right) all the time.
Is spriting not done properly or is it a Firefox problem ?
I think it's a Firefox problem as there are some bug reports about shaking images in Firefox.
It seems that when I move the background-image style onto the individual selector the vibration stops: See Demo
Example:
// Vibrates
.a, .b {background-image: url(example.png); background-size:50%;}
// Doesn't Vibrate
.a, .b {background-size:50%;}
.a {background-image: url(example.png);}
.b {background-image: url(example.png);}
I had the same problem with the vibrating background images in firefox when resizing the sprite. After adding the background-image to each instruction the problem went away, so the fix is not limited to just your demo.
Personally I'm starting to doubt this approach of resizing the sprite. I'm doing it as a solution for retina devices, but it seems the code is harder to maintain and the sprites are less precise (as not all browsers support fractions of a pixel well). The end result is:
Vibrating bug in firefox and the needed workarounds
The background-position values are just off enough to cut images off in an odd manner
Needing a solution to multiple all values by 50%, which means I can't just copy and paste the generated code from a sprite maker.
Related
I'm working on a site where we're using the background-image: url('') CSS property.
It works well, but it seems that background-position is calculated differently in Firefox than in Safari/Chrome.
In my code (below) the image to the right (right-floater class) doesn't seem to render the same. Open up the fiddle in both Firefox & Chrome to see what I'm talking about - in Firefox the positioning of the background image is much lower than in Chrome/Safari.
I'm using background-position: 50% 0%; which works well in Chrome/Safari but with Firefox it seems that background-position: 50% 100% gives the same results while 50% 0% end up making the site look pretty bad in FF.
I've tried to play around with a lot of the elements and it seems like this is the culprit...
What is going wrong?
body {
background-color: gray;
}
.left-floater {
height: calc(100vh - 75px);
width: 40vw;
background-image: url(https://cdn.shopify.com/s/files/1/2296/3395/files/TOMO-Website-R3-06.svg?10381558204658209910);
background-size: 50% auto;
background-repeat: no-repeat;
background-position: center;
display: inline-block;
}
.right-floater {
background-image: url('https://cdn.shopify.com/s/files/1/2296/3395/t/2/assets/Sculpture.jpg');
background-size: contain;
background-repeat: no-repeat;
width: 54vw;
height: calc(100vh - 75px);
display: inline-block;
background-position: bottom;
background-size: auto 100vh;
background-position: 50% 0%;
}
<div class="sticky-wrap">
<div class="left-floater"></div>
<div class="right-floater"></div>
</div>
View on JSFiddle
I have div with next styles:
.top-pattern {
width: 1024px;
height: 92px;
background-image: url("https://s21.postimg.org/p0amqt8wn/pattern-top-big.png");
background-repeat: repeat-x;
background-size: contain;
}
It is pretty simple and works great. But at some devices (mac and mobile) there is weird line appeared under the div. What is this? How to remove it?
Example: https://jsfiddle.net/wx92fb61/
Screenshot: https://gyazo.com/3020d6720d27fcbd0315a55fce0fb016
P.S. I checked my image hundred times: there is NO line in the image.
you css must be like, for example :
#media (min-width:768px;){
.top-pattern {
width: 1024px;
height: 94px;
background-image: url("https://s21.postimg.org/p0amqt8wn/pattern-top-big.png");
background-repeat: repeat-x;
background-size: contain;
}
}
#media (max-width:768px;){
.top-pattern {
width: 100%;
height: 94px;
background-image: url("https://s21.postimg.org/p0amqt8wn/pattern-top-big.png");
background-repeat: repeat-x;
background-size: contain;
}
}
in phones or tablets you better have a width of 100% than a pixel value, then you should add a initial scale in the head part of your html to catch a fixed value for the devices.
See, if you can override this CSS class and remove box-shadow.
I think this is what is getting you that border.
.image-box-component .image-viewer {
box-shadow: 0 0 0px rgba(0,0,0,0) !important;
}
I have read so many posts about responsive CSS Background-Image's but I can't make mine work.
My site is http://www.conn3cted.uk.tn/intManagement.html and I'm trying to use the image as a 'banner' so can't have the height too large.
I seem to be able to fix the issue either on Desktop or Mobile, but they don't want to work together. I've used the suggested solutions (below) but I don't get the whole picture to scale up/down and it only shows part of it or a lot of white space. What am I doing wrong!?
.whatWeDo {
padding-top: 100px;
background-image: url("/images/intManagement/homePage/whatwedo.jpg");
background-repeat: no-repeat;
background-size: cover;
background-position: center;
height: 120px;
}
Try this css and use media queries to change your margin-top for mobile device:
.whatWeDo {
background-image: url("/images/intManagement/homePage/whatwedo.jpg");
background-repeat: no-repeat;
background-size: 100% auto;
height: 100vh;
margin-top: 80px;
}
#media screen and (max-width: 878px) {
.whatWeDo {
margin-top: 170px;
}
}
Try this css with replace your css:
This can also responsive only set top as per you needed:
.whatWeDo {
background-image: url("/images/intManagement/homePage/whatwedo.jpg");
background-repeat: no-repeat;
background-size: 100% 100%;
float: left;
height: 100%;
padding-top: 100px;
position: relative;
top: 80px;
width: 100%;
}
I have a client that wants the same image style effect as WooTheme's Duo Theme. I can easily achieve this initial effect:
------HTML-------------
<div class="home-banner">
</div>
-------CSS-------------
.home-banner {
height: 500px;
background-image: url("CLIENT'S BG IMG");
background-repeat: no-repeat;
background-size: cover;
background-position: center;
padding: 9.505em 1.618em 11.089em;
text-align: center;
box-sizing: border-box;
position: relative;
overflow: hidden;
}
.home-banner:after {
content: "";
display: block;
height: 10em;
width: 200%;
position: absolute;
bottom: -5em;
right: -20em;
background: none repeat scroll 0% 0% #46535D;
border-radius: 100%;
transform: rotate(2deg);
border-top: 0.327em solid #F97960;
}
But there is one requirement that is killing the whole thing. The client's photo is showing staff members of their company. When the browser window is resized to simulate a tablet/smartphone, most of the image cannot be seen due to the css rule:
background-size: cover;
If I change this rule, the banner effect no longer works properly. I need all staff members to be seen on a small display. Imagine a staff member's head being cut off on their mobile device. That means that my head would be next. Any suggestions?
You can use a CSS media query such as
#media (max-width: 480px){
/*Place mobile CSS here*/
}
This way whenever a user looks at this on a mobile device this CSS rule will override the normal browser one... just place it after the normal browser styling.
I've managed to get my header to work as a link in ff, safari and opera with the css image replacement
#header h1 {
background-image: url(../images/logo.png);
background-repeat: no-repeat;
text-indent: -9999px;
margin-left: 15px;
}
#header h1 a {
display: block;
height: 120px;
width: 400px;
margin-top: -135px;
}
I'm trying to optimize the site its for in IE, my last step before I launch it on monday but the logo doesn't appear at all in IE 8 or 9, But it very surprisingly does in IE 7. I managed to get the logo to appear in IE9 by making the display inline-block
.ie9 #header h1 {
background-image: url(../images/logo.png);
background-repeat: no-repeat;
text-indent: -9999px;
margin-left: 15px;
}
.ie9 #header h1 a {
display: inline-block;
height: 120px;
width: 400px;
margin-top: -135px;
}
bit the image is no longer a link when I do this, does anyone have any idea how to fix this? I would put the image in the HTML instead of using the image replacement but Its been hammered into my head that from an SEO standpoint using the image replacement is better.
I think it is the margin-top: -135px causing the problem. The height is only 120px so it will end up being -15px (height - margin) so disappearing underneath the bottom of the H1 tag.