Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Background image not showing in Safari

I am working on a responsive design and the class "bgMainpage" is having a background image but it is not showing on Safari on all the devices. I have applied background size cover as it is what the client wants. I have added browser specific CSS too and I am not sure what else to do so that it shows up in Safari too. Chrome, FF, IE show the image just fine. Any ideas ?

Project Link

CSS :

.bgMainpage{     background:url("../images/bg.jpg") no-repeat scroll right top #000000;     -o-background-size: cover;     -moz-background-size: cover;     -webkit-background-size:cover;     background-size: cover; } 
like image 329
AspiringCanadian Avatar asked Jun 27 '13 11:06

AspiringCanadian


People also ask

Why are images not showing in Safari?

Check what version of Safari your Mac uses. For earlier versions of Safari (versions 8 and below), go to Preferences and choose Appearance and then choose to Display images when the page opens.

Why is my background image not showing up?

Make sure the image path is set correctly in the background-image url. Once you have made sure that your CSS file is linked correctly, also check that the image itself is set correctly. Again, you will want to open your code inspector in the browser to check.

How do I fix my Safari background?

From the start page, click the Menu button from the bottom-right corner of the screen. Now, check the box next to the “Background Image” option. Here, you can scroll horizontally to see bundled background images. Click an image to instantly turn it into the start page's background image.


1 Answers

Safari has an apparent bug where it won't show some jpg/JPEG images of a certain type in backgrounds if some criteria are met. For online use there is a type of jpg image called Progressive JPEG. Regular jpg images encode the image data from top to bottom, and you can see them load that way online. Progressive JPEG, on the other hand, encodes the image in progressively higher detail. This means that it loads fuzzy at first and then gets clearer. Some people think this looks better online, which is why it's used. Some image optimizers will automatically make jpgs progressive for online use.

In my experience, Safari won't display jpgs when some of the following criteria are met:

  • progressive encoding is used
  • the image is a background (for an element or the whole page)
  • the image is large (I don't know how big exactly, but I ran into problems with images that were in the thousands of pixels wide)
  • possibly other things, I haven't fully explored this bug

I have not been able to recreate this in any browser except Safari.

To fix this, you can either re-save the image, making sure that it isn't in a progressive format (photoshop, etc have a selector for this), or use another format (gif, png, etc)

like image 61
JC Hulce Avatar answered Oct 06 '22 01:10

JC Hulce