Solved

background attachment:fixed ignores min-width

Posted on 2014-10-02
7
113 Views
Last Modified: 2014-10-21
Hi

i have a background image on body tag nad is set to background-attachment:fixed.

However this causes the min-width property of body and html tags to be ignored and the background keeps moving left on smaller screens

See what i mean here - http://dev.openwaterdesign.com/cutting_edge_coaching/

Any ideas how to solve?

Thanks
0
Comment
Question by:coolispaul
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40357835
The background shifts because you positioned it center top so it keeps the center of the image in the center of the vieport, and that forces it to move.

Min-width is doing exactly what it is supposed to do when the viewport gets less than 960px it adds scrollbars.

Cd&
0
 

Author Comment

by:coolispaul
ID: 40357875
So why then is the background moving left if the width is 960px?

the background should be central to 960px but its not doing that

Thanks
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40357992
The image is 1366x918. Therefore its center is 683px from the edge and as the viewport narrows has to shift to compensate and keep 683 in the middle of the viewport.  Background images are not part of the content and they do not adjust to content position.

Cd&
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 52

Expert Comment

by:Julian Hansen
ID: 40358042
You could try changing
body {
  background: url("../img/banner-home.jpg") no-repeat scroll center top #000;
  font-family: "Roboto",sans-serif;
}

Open in new window

To
body {
  background: url("../img/banner-home.jpg") no-repeat scroll left top #000;
  font-family: "Roboto",sans-serif;
}

Open in new window

That will stop the background image from shifting - if that is what you want it to do?
0
 

Author Comment

by:coolispaul
ID: 40358045
well it does actually work like i want  when you remove "background-attachment:fixed". This is causing the problem,
I do however want the bg fixed...

Ta
0
 
LVL 52

Expert Comment

by:Julian Hansen
ID: 40358188
You get the same effect by changing the center to left as shown in my previous post.
0
 
LVL 15

Accepted Solution

by:
Jagadishwor Dulal earned 500 total points
ID: 40365225
Use the fixed attachment with in background attributes like:
background: url("../img/banner-home.jpg") no-repeat fixed center top #000;

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
My dialog box isnt work, no box displays but text does 8 38
Javascript Hashmap output 8 46
P tag not forcing line space 2 23
Why my select dropdown does not work? 8 27
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now