question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default 25px on background position's y axis

See original GitHub issue

Hi Mark,

First I really love this plugin. And it’s the first time I use it for my project. But I got an issue with the plugin. Here’s a short story what I did with your plugin.

I create a section at the very top. This section will have parallax background via data-stellar-background-ratio=“0.5”. I set the section’s style to set

background-size: cover;
background-position: center center;
background-attachment: fixed
/* this will create the background image size follow the viewport's size, and it's needed. */

and I set the stellar options like this:

$.stellar({
    horizontalScrolling: false,
    responsive: true,
});

And I fire the script on document.ready. I noticed that when stellar is initiated, it set the background-position to 50% 25px. I don’ understand why it gives default 25px on the background-position’s y axis.

And then after the window is loaded, as I set the responsive to true, the plugin will calculate the background position. It sets to 50% 50%. But when I scrolled down the page and scrolled back to the very top. It sets to 50% 25px again.

It turns out that I set the ratio to 0.5 it will give you 25px and if I set the ratio to 0.25 I will have 12.5px.

My questions:

  • Why the plugin give non-zero initial y axis? I think it should be 0px on y axis position.
  • Why your responsive mode reset it to 50% 50%. I believe it should be 50% 0px. This will create a flash which is not good on the eye. Because on ready state you set it to 50% 25px and then on window loaded you set it back to 50% 50%.

Thanks

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:1
  • Comments:21

github_iconTop GitHub Comments

2reactions
bitkiddcommented, May 10, 2015

This worked for me.

background-size: cover;
background-position: 0 0;
background-attachment: fixed;
background-repeat: no-repeat;
0reactions
ctrl-dcommented, Aug 9, 2017

i simply added verticalOffset: 50, and it works just fine

Read more comments on GitHub >

github_iconTop Results From Across the Web

background-position-y - CSS: Cascading Style Sheets | MDN
The background-position-y CSS property sets the initial vertical position for each background image. The position is relative to the ...
Read more >
CSS background-position change on Y-Axis only
I have a CSS sprite image made up of ten(10) 25px x 25px icons laid out horizontally - thus resulting in a sprite...
Read more >
background-position - CSS - Codecademy
Note: The default position will be in the top-left corner. ... Use pixels to place background image 100px down the y-axis and 100px...
Read more >
All you need to know about background-position
When dealing with background-position we have two common situations: ... of the container (same formula for the Y-axis considering height).
Read more >
background-position | CSS-Tricks
The default values are 0 0 . This places your background image at the top-left of the container. Length values are pretty simple:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found