Solved

background attachment:fixed ignores min-width

Posted on 2014-10-02
7
122 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 57

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 57

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Text too large in Chrome 17 81
TypeError jquery issues with site - CSS conflicts 3 43
Div not showing up 6 31
Drag & Drop Error 5 24
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Find out what you should include to make the best professional email signature for your organization.
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 style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

740 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