Background images on mobile devices not displayed correctly - html

I'm making the layout in sections. Image/Text/Image/Text... and the images have this CSS :
#change {
background-image: url("../images/main.png");
background-attachment: fixed;
background-repeat: repeat;
background-size: cover;
}
HTML
<section id="change"
data-type="background"
data-speed="5"
data-selection="0"
style="height: 630px;
background-position: 50% 16px">
On a PC the images are displayed nicely. But on a mobile device the images are not corresponding to the CSS but displaying in full-res. Hence I see only a corner of a 5000x3500px image. I'm using Bootstrap in this project and Safari (iPhone 4s).
It's currently on a free host so excuse me for adds. (Also I didn't work yet on minimizing load time for the images, so sorry for that too.)
The website:
http://viso.lv/imigracija/
UPDATE: It seems that only iPhones have a problem of displaying the images. Because several people with other phones have the images just right. What can I do about that? I tried 3 different browsers. Nothing changed.

I don't quite understand what you're asking. For me (Samsung Galaxy S3 Mini) the images look fine. There's some lag when scrolling, but that's perfectly natural for a mobile browser (Firefox Mobile) handling large images with CSS.
Unless there's another issue other than positioning, which is the fault of a browser without strong CSS skills, then there isn't much you can do, sorry.

Related

Mobile fixed image background css, image scrolling

I'm making a website for my girlfriends 23rd birthday and she'll mainly be viewing on mobile. The background image is fixed (no issue on desktop) but on mobile, the image scrolls slightly on the bottom, but adjusts itself after scroll. (Video Attached: https://youtu.be/wKnxYXEy0mg)
CSS Below:
body {
background-image:url(Gold2.jpg);
display: block;
background-color: gold;
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
background-position: center;
min-height: 500px;
}
That's not the background moving, it's Chrome's address bar disappearing.
This behavior is normal, try the website on a different browser.
Have you already tried to force off this behavior by using jQuery? jQuery makes it tremendously easy to add and remove classes as well as adding css to them. You could create an if-statement that manually adds the css rule of this background to the section. Another option I'd consider is to add new classes for everything you need in this case scenario and giving everything a z-index above 1 (just to be sure everything is displayed in the chrome browsers mobile app properly). That are just guesses I would realize in your situation although I didn't know this behavior to this point. Hopefully I helped you with your problem... :^)

Why does the background image not cover the whole page sometimes?

I have an HTML page where I have an image as a background. Whenever I view the page on my iPhone 6, the background image sometimes doesn't cover the whole page. This happens only about 20% of the time and doesn't happen after reloading the page. It always happens when I clear cache and website data on my phone. This is the CSS to set it to the background(I got it from the web by searching "how to make a good CSS background image")
html { /*Copied from the web*/
background: url(img/sea.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
body{
background: none;
}
The url of the page is msolonko.net/signup.php.
As you can see on the image, there is white space below the login button. Why does the image work correctly sometimes, but rarely not? How can I fix this?
EDIT:
Changing resolutions of the image has no effect on the issue.
I do not want the image to repeat. It looks good with just one image if the issue doesn't occur.
Also, if I cannot fix this issue, I will make the image only appear if it is a computer. If the device width is less than some threshold, I will just use a background color instead of image. I am still hoping I can fix this though.
Two solutions: Make it so the image repeats (turn no-repeat to repeat) or..
Increase the height of sky.jpg since sky.jpg is not tall enough to fit the phone.
So if I'm not mistaking (which I probably am), you should make your sky.jpg image 960 x 660 pix. Some average phone pixel resolutions at http://www.binvisions.com/articles/tablet-smartphone-resolutions-screen-size-list/
This should help! Sorry if it didn't.
EDIT: Did you at least try the techniques? (I'm new to Stack, I can't comment)
edit the image before you load the page, make the correct size for it and there you got.
be recursive.
(i have the same problem and do it this way becouse i found no way to find a solution in the code.)
i use programs like photoshop and corel.
I got it! I was learning some CSS... CSS Code:
body {
background-image:sky.jpg; /*or whatever*/
}
Should work...maybe.

CSS Background Image not displaying on mobile

i've added background images using CSS on the banner section of a few pages on a Wordpress site and they work fine on desktop on Chrome/Safari/IE/Firefox using auto-prefixer. For some reason on mobile browsers (I've tested on Chrome and Safari on my iPhone), some of the banner images display correctly while the others do not.
.banner {
position: relative;
overflow: hidden;
background: -webkit-linear-gradient(bottom left, rgba(37, 17, 36, 0.45), rgba(37, 17, 36, 0.45)), url(img/banners/home.jpg);
background: linear-gradient(bottom left, rgba(37,17,36,0.45),rgba(37,17,36,0.45)),url(img/banners/home.jpg);
background-size: cover;
text-align: center;
background-position: center center;
}
The image on the left is of a page which displays the background image correctly and the image on the right is of a page which does not. Both have exactly the same css apart from the image used:
UPDATE:
After some advice from the guys, I tried to resize some of the images to see if they worked on Chrome/Safari on Mobile:
As you can see the resized images did work on both Chrome and Safari on my iPhone. Apple's IOS documentation recommend a maximum size of 1024px but 1400px worked fine for me (although I did have to delete cookies and data in Safari settings on my phone)
So, what are some other differences between those two images? Mostly pertaining to pixel size.
Mobile Safari has a pixel threshold, which actually has nothing to do with size in kb of the image, but the amount of pixels. What are the sizes of the images that aren't displaying? Are they longer or taller than the ones that are?
Here is a link to the Safari Web Content Guide. Scroll down to the Known iOS Resource limits and see if you fall under any of those categories!
This 2014 question is apparently still relevant in 2021. I just had an issue of a full page background image not loading on a OnePlus 5 when it loaded fine on every other device. Resized the image to 1400px width as per above comment from SlightlyClever, made that variant the one shown on mobile version, and it loads up fine. At the same time cut down the download from ~3MB to a bit under 1MB so that's nice too.

UIWebView displays image differently on iOS6 and iOS7

Basic Scenario:
I have an image that is 2048x1536.
I have an html file that displays this image via CSS that specifies a width of 1024 and height of 768.
I have an UIWebView that displays that html page.
Problem:
On an iOS6 device, that image is resized to fit within that 1024x768 area. On an iOS7 device, that image is cropped to only display the top left quarter of the image.
Since iOS7, Chrome, and Safari all do the cropping option, I do believe that is the correct behavior (I strongly suspect that the latest webkit was updated to match this standard behavior). However, for business reasons, I still need the resize behavior.
Question:
Is it possible to still to keep that resize behavior even on iOS7?
EDIT - Additional info based on comments:
I presented a highly simplified scenario. I can't just put the image into an image view. The feature within my app allows 3rd parties to load their HTML content into it. Also, related to that, I can NOT modify the HTML contents. Basically, all I can do is create a NSUrlRequest for that HTML content and tell the UIWebView to load it via loadRequest.
Below are the HTML snippet and CSS snippet. But please keep in mind that I can't change this. I only control the objective-c end of things.
<body >
<div id="wrapper">
</div>
</body>
#wrapper {
background-color: #FFF;
position: relative;
width: 1024px;
height: 768px;
background: #FFF url(images/bg.jpg) no-repeat top left;
background-size: contain;
overflow: hidden;}

iPhone CSS Background Resize

I'm currently working on a WordPress theme and I've got it up & running here: http://tinyurl.com/kawesnh
I'm trying to make the image shown in the background cross-compatible with the iPhone's safari browser, but have failed to do so :)
I'd like to have the background scroll with the page's content, but haven't found how to do this, while also having the background resize for the iPhone browser.
Here's my CSS, which produces an initially good-looking layout on the iPhone, but resizes the content after a link is clicked, also it's producing a bad result on desktop browsing:
CSS
body {
background: url(http://www.myurl.co/tq/wp-content/uploads/2013/07/TQ-Oceanside_BGtaller.jpg) no-repeat center center fixed;
background-position: center top;
background-color: #000000;
}
Thanks for your help!
Try using CSS3 media queries. Media queries are used by most themes on wordpress because they make your website responsive and makes your background resize to the browser's size. Here's a tutorial:
https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries