?
Solved

background attachment:fixed ignores min-width

Posted on 2014-10-02
7
Medium Priority
?
131 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
LVL 58

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 58

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 1500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
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 …
Suggested Courses

752 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