Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4334080
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:28:47+00:00 2026-05-21T10:28:47+00:00

Pretty straight forward I suppose. Getting the background position is easy, but just getting

  • 0

Pretty straight forward I suppose. Getting the background position is easy, but just getting the Y position seems to be a bit tougher. Do I have to splice up the background position output? Or is there a cleaner way of getting the value?

EDIT: I was able to get this, the javascript version of Damien-at-SF’s answer, but for some reason yResult returns ‘(an empty string)’ when I do a console.log() for it.I don’t think it’s actually grabbing the value. What am I doing wrong?

var yResult = document.getElementById('sub-image1').style.backgroundPosition;
var a = yResult.split(" ");
var y = parseFloat(a[1]);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T10:28:48+00:00Added an answer on May 21, 2026 at 10:28 am

    You could use jQuery for wide browser support:

    //returns y position of background image
    $("#example").css("background-position").split(' ')[1]
    

    Working example here: http://jsfiddle.net/QagqS/

    That example alerts the y position of the background image 🙂

    UPDATE WITHOUT JQUERY:

    For standard javascript ( http://jsfiddle.net/QagqS/3/ ), you need to define your css inline, within the element:

    <div id="example" style="background-position:10px 100px"></div>
    

    This allows the javascript to pick up on the style of the element and as such you can use the

    document.getElementById('example').style.backgroundPosition.split(' ')[1]
    

    method posted above…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I thought this was pretty straight forward but I don't get the same results
I have a side project I do = in Java. It's a pretty straight-forward
This is a pretty straight forward attempt. I haven't been using python for too
I'm currently working with Groovy and Grails. While Groovy is pretty straight-forward since it's
Pretty straightforward, but I just want to know which is faster. I think simply
Pretty straightforward stuff, here -- I'm just not good enough with mysql to understand
My question is pretty straightforward: You are an executable file that outputs Access granted
For the following pretty straightforward task: query a list of products from a DB
I'm writing a pretty straightforward e-commerce app in asp.net , do I need to
Shouldn't this be a pretty straightforward operation? However, I see there's neither a size()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.