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... :^)
Related
I have a 1920x1080 JPEG background image that I am using on a 1920x1080 screen.
It has the following properties:
background-image: url(/bg.jpg);
background-attachment: fixed;
background-position: center top;
background-repeat: repeat;
In Chrome, without the background-position: center top; the background is perfectly scaled and sharp. With this property added, the background loses sharpness.
Weirdly, if the browser width is an odd number, the image is perfectly sharp. So 1920x1080 would be a bit blurry, but 1919x1080 would be perfect.
In Edge and Firefox, the background image is perfectly scaled in either case.
The background-position property is required for proper positioning due to scroll bars on some browsers.
I have tried image-rendering. The only property that I could actually see a difference with was pixelate, but it caused tearing at some parts.
I have trialed lots of different property combinations (background-size), but I definitely could've missed something.
My question is the title:
How to stop background-position making the background image less sharp?
But the answer to this question would also resolve my problem, as I think that this might be a bug or at least an after-effect/result of one of Chrome's features:
How to stop Chrome resizing (or doing something else) to a background image when it is being positioned?
There could be multiple reasons why this is happening.
I'd take a guess and say that the background-size isn't being set. I would be tempted the have this set to background-size: contain to keep your ratio in tack. Also when you are using background-attachment: fixed; make sure the div is position: static.
Hope this help, if not, supply a jsfiddle and I can take a look.
image-rendering: pixelated;
it works for me.
I am using Bootstrap, HTML and CSS for my website. I built it on my Macbook Pro, and now when I move to my desktop monitor (which is much larger), there seems to be a large white space on the right side of the web page due to the monitor being much larger in width.
The height is working perfectly fine and it scales well, but it seems like right when the image ends (width) the site wants to keep going, but is not stretching the image to fit the larger monitors horizontally (width).
How can I fix this?
Image of Website Problem:
This is what I came up with so far.
body {
background-image: url("http://i.imgur.com/vDF3k2s.jpg");
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-repeat: no-repeat;
width: 100%;
overflow: auto;
font-family: Lato;
}
html {
height: 100%;
}
I appreciate all suggestions, thanks!
Without your HTML code, I can't exactly replicate what you are doing, so I will have to assume some things... always dangerous! LOL!
Anyway, I will first tell you what I believe is going on, then I will explain some things to do to combat that, and then I will provide the actual code, based off of the code you have already supplied.
Ok, I believe what is happening is that since you haven't specified where within the body you want the background image, by default the browser is giving you the image at 100% of it's original size and floated to the left.
In order to get a fullscreen image, which is what I believe you are shooting for, I would first place the background image within the "html" tag instead of the "body" tag. Second, I would let the browser know that you want the image to be centered and not to repeat. Then I would tell the browser that you want the image to "cover the screen".
So, with that said, here is the code for what I just explained:
html {
background: url("http://i.imgur.com/vDF3k2s.jpg")no-repeat center;
background-size: cover;
overflow: auto;
}
I should explain that I have deleted the -webkit, -moz, etc. portions of the code. That is because "overflow" is compatible with so many older versions of the most commonly used browsers, that to write that in your code is unnecessary.
Also, when I'm creating a fullscreen background image on a page, I usually use "background" instead of "background-image" and I have the "overflow" as "hidden". I can't honestly tell you if that is a "best practice" or if your writing "overflow" as "auto" is, but I also don't know what other content you plan to put in place, etc.
Anyway, I hope my solution helps and please hit me back to let me know!
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.
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;}
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