Android/ phonegap - Stretching my background image to fit screen - android

I have tried various differnt things however none of them seem to work. I am using inline CSS and simply want to add a background which stetches to the screen size. I am currently using the following code within my body tag:
<body onLoad="onBodyLoad();" style="background:url(images/blue_bg.png);">
My image is 400 x 300, but need to be streched to as far as 1200 x 1000.
Hope someone can help (have tried background-size:100%).
Thanks,

You can try this CSS3 code:
body{
background: url(images/blue-bg.png) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
If this doesn't work you can try :
Other CSS techniques
jQuery techniques

Related

White space at the bottom of the page on tablet/phone

I use a image as page background, this is the code:
body {
background-color: black;
background: url(/images/bg.jpg);
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-repeat: no-repeat;
background-attachment: fixed;
background-position: 100% 0%;
}
It looks okay on computer but if I open the page from a tablet or phone there is white space at the bottom of the page.
Here is how it should look:
And here is how it looks on tablet:
try,
html, body{
height: 100%;
}
Due to different aspect ratios of the image itself and tablets (many of them), you will always get some blank space when you use cover. Using height 100% will actually cover the entire height, but will stretch the image.
What you may need is to compare the aspect ratios of the image and the screen of the device and then try to use background-size (percentages) to zoom in or out of the image in order to cover everything in all devices.

Resizing Background on ipad/tablet

All currently developing this forum/site:
http://nfldynasty.boards.net/
Lots to finish in terms of content, however I'm currently having some problems resizing the various backgrounds on mobile devices such as ipad and Samsung android tablet etc.
All seems to work well when viewing on laptop via both google chrome and internet explorer.
The code I'm using is as follows
body {
-webkit-background-size: cover;
-ms-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
html { height: 100%; width: 100%; }
I cannot seem to work out a way of adjusting the background size on ipad/tablet etc without either changing this on internet explorer to changing the size of the text boxes. i.e. when I change the html tab from 100% to say 75% the background remains unaltered but the size of the forum categories reduces
If I remover the final html line then on all devices the image is distorted when zooming in and out on the text.
Any ideas?
You can try using this for smaller screens:
body {
background-color: #000;
background-size: contain;
background-position: center top;
background-repeat: no-repeat;
}

White space is coming while switching from portrait to landscape in android mobile

I am trying with html 5 and css 3 for creating mobile application where i tried with 1px strip image repeat. I tested in mobile native browser.While i change from portrait to landscape i found background flicker with a white background.
I also tried CSS3 background gradient, it seems to be not render fully till the html page ends, this is the style i used in my css style sheet
body{
background-image: url('../images/bg_strip.png');
background-repeat: repeat;
height: 100%;
overflow:none;
}
i am not sure but i am trying tos give you a good answer hope it will work fine to you.
background: url(images/bg_strip.png) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;

Strange behavior with Background-image on stock android browser

Whenever I use the below CSS (I also declared it with the shorthand and got same result) I get this strange "BES" that appears for a split second on the page when viewed on certain Android Stock browsers.
html {
background-image: url(http://www.cynthiapacephotography.com/wp-content/themes/pace_origin/images/background2.png);
background-repeat: no-repeat;
background-position: center center;
background-attachment: fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
Even if I remove all the extras and just leave it like below, I still get the weird letters
background-image: url(http://www.cynthiapacephotography.com/wp-content/themes/pace_origin/images/background2.png);
I don't get this on the iPhone or Chrome on Android devices. I finally just added a media query and just using a background color on mobile devices. With just the background color and no image, I don't get the letters anymore. I also tried a handful of background images and this always happens when using a background image.
Any ideas of what this is and what's causing it?
Here's a shot of what I see:

Repeating a background on Android

I have a mobile responsive theme that I have created, and it works great.. On everything except android. The background image loads and looks fine, but it does not render on parts of the site that are not in view when the page is loaded. Any time you scroll down the page, the background is white. The code that I have at this time is:
body
{
background: url('images/MobileBack.png') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
I have tried some other variations of this declaration, but to no avail. Is there a way to load the background on Android using just CSS, or do I have to delve deeper? (PS. it works fine on iPhones and iPads).
Okay, the issue was the center center fixed appendage to the background declaration.
you need to use media query to fix this problem
#media screen {
background: url('images/MobileBack.png') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
hope it works if not then if you don't mind let me see its screen shot

Categories

Resources