Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Background Image not Displaying Correctly on Mobile Devices

Featured Replies

Hi people,

 

Ive never designed a website for moble devices before or one that uses a full blown background image. So please go easy on me..

 

Anyway, I have a full background image that i want to display on my site.

 

Its working fine on all desktop browsers however when I test it on my iphone and ipad the image is slightly broken at the top and at the bottom.

 

here is my (at the moment) very basic css code:

 

body {
	font: normal .80em arial, sans-serif;
	color: #DDD;
	background-attachment: fixed;
	background-color: #FFF;
    background-image: url(../images/back.jpg);
	background-repeat: no-repeat;
	background-position: center;
}

Really gratefull if anyone can tell me what im doing wrong here.

 

Thanks in advance.

u can use css media queries and use different sized bg image like this

 

* Smartphones (portrait and landscape) ----------- */
@media only screen 
and (min-device-width : 320px) 
and (max-device-width : 480px) {
/* Styles */
body {background-image:url('paper9.gif');
}

/* Smartphones (landscape) ----------- */
@media only screen 
and (min-width : 321px) {
/* Styles */
body {background-image:url('paper8.gif');
}

/* Smartphones (portrait) ----------- */
@media only screen 
and (max-width : 320px) {
/* Styles */
body {background-image:url('paper7.gif');
}

/* iPads (portrait and landscape) ----------- */
@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) {
/* Styles */
body {background-image:url('paper6.gif');
}

/* iPads (landscape) ----------- */
@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : landscape) {
/* Styles */
body {background-image:url('paper5.gif');
}

/* iPads (portrait) ----------- */
@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : portrait) {
/* Styles */
body {background-image:url('paper4.gif');
}

/* Desktops and laptops ----------- */
@media only screen 
and (min-width : 1224px) {
/* Styles */
body {background-image:url('paper.gif');
}

/* Large screens ----------- */
@media only screen 
and (min-width : 1824px) {
/* Styles */
body {background-image:url('paper2.gif');
}

/* iPhone 4 ----------- */
@media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
body {background-image:url('paper3.gif');
}
  • Author

Thanks Sash, Ive been playing around with it and seem to have it
working now, although I will try out the media queries you posted.

 

Thanks for your help dude.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.