Header image placement on IOS - html

My header image on my website (dorinart.com) is perfectly positioned in all browsers including android mobile browsers but when I open it on IOS (iphone, ipad) it only shows the top right corner of the image (you can check if you open dorinart.com). How could I resolve this issue?
my css looks like this:
.header{
background: url('../img/banner5.jpg');
background-repeat: no-repeat;
position: fixed;
background-size: cover;
min-height: 730px;
position: relative;
}

Can you try this CSS? I think you want to center the image in the space available right? Please let me know if this works:
.header{
background-image: url('../img/banner5.jpg');
background-repeat: no-repeat;
background-size: cover;
background-position-x: center;
min-height: 760px;
position: relative;
}
If you don't want it centered, then just remove the background-position-x property.
Hope this helps. Thanks.
Update: Attached screenshot from simulator:

I have had a similar issue recently and realised that it's due to background-size:cover with background-attachment:fixed.
In your website its like this:
background: url('../img/banner5.jpg') no-repeat fixed;
background-size: cover;
min-height: 760px;
position: relative;
Here the background-attachment:fixed is the problem.
I solved the issue by using a media query for iPhone and setting background-attachment property to scroll.
So what you can do is use this:
.header{
background-size: cover;
background-attachment: fixed;
#media (max-width: #iphone-screen) {
background-attachment: scroll;
}
}

Related

CSS Background Image not covering whole viewport width

CSS background is not covering whole viewport width while using media query #media (max-width: 62.5em)
I tried using background-size: cover, background-position: top left, background-repeat: no-repeat but still nothing works.
here's main CSS styles of that section.
max-width: 100vw;
min-height: 100vh;
background: url(../images/bg-hero-desktop.svg);
background-color: #ebfbff;
background-size: cover;
background-repeat: no-repeat;
padding-top: 20rem;
padding-left: 5rem;
This is a fairly common error that I experience at times while working on layout.
The problem is NOT with the background of the html component, but rather with the layout on your footer, and your footer-cta-box div. These elements are pushing the layout outside of the viewport which is what is making it appear as though the background for the html is not rendering correctly. If you use "Inspect" in your browser to temporarily take out those elements you will see that the html background renders correctly! You're doing things right!
I'm not sure exactly how you want the footer and footer-cta-box to be laid out on the page, or else I could help you to get them in the right place, but those are the culprits of the problem.
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
body {
background: url(https://www.nasa.gov/images/content/296150main_2-226.jpg) no-repeat center center fixed;
background-size: cover;
}
main {
color: white;
}
<main>Hello world</main>
try
background-size: contain;
or
background-size: 100%;
instead of
background-size: cover;

Background-size doesn't work on mobile

I really don't know why this is happening, I guess I'm tired, but the question is that the "background-size" doesn't work on my mobile devices, just when I tried to simulate on the browsers that I used in my PC.
Take a look:
PC looks like these: Image
Mobile... Image
Ah! The codes:
#media screen and (max-width: 888px) {
body{background: url(../img/bgm.jpg) fixed no-repeat; background-size: cover;}
}
Thanks
Give this a whirl, just add it in your /head/
<meta name="viewport" content="width=device-width, initial-scale=1.0">
credit: https://www.w3schools.com/css/css_rwd_viewport.asp
If this doesn't fix it, it could be your background-position size if you have a div with a background image try contain as opposed to cover on the mobile version, or just upload the image that has the appropriate size, for ex: if the header is 300px wide by 150px height just resize the image to that
Finally worked!
After a deep search, I found this: background: fixed no repeat not working on mobile
body:before {
content: "";
display: block;
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: -10;
background: url(photos/2452.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

How do I get my background image to not be cut off at the bottom?

I have a large background image that is fixed with text being displayed on top of it, however the bottom of the image is being clipped off. I want the image to be displayed completely and not be cropped off.
#content {
background-image: url(../images/bean.jpg);
background-repeat: no-repeat;
background-size: 100%;
background-attachment: fixed;
height: 40em;
margin-top: 0;
padding: 0;}
Set background-size to be 100vw 100vh i.e background-size: 100vw 100vh;
#content {
background-image: url(http://lorempixel.com/1400/1400/sports/3/);
background-repeat: no-repeat;
background-size: 100vw 100vh;
background-attachment: fixed;
height: 40em;
margin-top: 0;
padding: 0;}
Checkout this DEMO: http://jsbin.com/buqaju/1/
To have the background always cover the whole container you can use:
background-size: cover;
Source: http://css-tricks.com/perfect-full-page-background-image/
Pay attention to browser support: http://caniuse.com/#search=background-size (hint: No IE8)
Also, I noticed it's not very performant on pages with a lot of transparencies and moving backgrounds, but other than that I use it quite a lot and it works well.
Increase the height?
height: 100em;
you have
background-size:100%;
use
background-size: 100% 100%;
.bg_care{
background-image: url(../img/care-area.jpg);
background-size: cover;
}
just use background-size as cover it wont cut off.
You could also modify your background as such:
background: url(xyz.jpg) no-repeat **center center** fixed;
where you change the center values as needed (left,right,bottom,top). Depending on the image it may be useful.

Background size on iOS

I've spent the morning doing research on the following issue. I'm making a one page site, using a lot of images. I'm aware that Safari is known for its weird handling of background-attachment:fixed, but that's working fine; my problem is background-size:cover is not working in conjunction with fixed.
I have 5 pages, all of which have a height or min-height of 100%. The last page is fixed like this:
#div5 {
height:100%;
width:100%;
position: relative;
background-image: url("img/background.jpg");
background-attachment:fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
On iOS (in both Chrome and Safari) the background image is scaled to cover the full webpage, so it's really stretched.
At the same time, page 4 has the following css:
#div4 {
min-height:100%;
width:100%;
background:url(img/portfoliobg.jpg);
overflow: auto;
background-size: cover;
}
and this works like a charm.
So, something makes the browser behave really weirdly when combining fixed and cover. Does anyone have a solution to this?
Use another div with position:fixed to make the background fixed.
Like this:
http://codepen.io/anon/pen/OVebNg
JADE
.fixed
.bgcover
SCSS
.fixed {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
.bgcover {
background-image: url('http://globe-views.com/dcim/dreams/winter/winter-04.jpg');
background-size: cover;
width: 100%;
height: 100%;
}
}
Hope this help.
Short answer: you can’t (for now).
You can play with #media screen and (max-width: 1024px) {} but for now iPad Pro have resolution more then ordinary monitors.
I offer you to disable fixed attachment for mobiles via this way:
Main CSS file:
.parallax {
background-attachment: fixed;
background-size: cover;
}
Main HTML
<script type="text/javascript">
if (navigator.userAgent.match(/(iPad|iPhone|iPod|Android|Silk)/gi)) {
document.write("<link rel=\"stylesheet\" href=\"fixparallax.css\" />");
}
</script>
Additional fixparallax.css
.parallax {
background-attachment: scroll !important;
}

Background size cover plus background attachment fixed not working in pages with scrolling in IE11

I've always been using the following piece of code to make a background fixed as well as covering 100% of the page despite its size:
background-image: url('./background.jpg');
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-repeat: no-repeat;
background-position: center top;
background-attachment: fixed;
background-size: cover;
However, since IE11, this is not working as it should:
This is how it was showing up until IE11:
Did anything change with IE11? Is there any way to make it work as before IE11?
Thanks to everyone for your comments! I found a way that actually Works in IE11. Placing the background as an image in an individual div with these properties: code height: auto; left: 0; min-height: 100%; min-width: 1024px; position: fixed; top: 0; width: 100%; z-index:-1; Check it here: nekutranslations.es/sf2