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 4610780
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:10:46+00:00 2026-05-22T01:10:46+00:00

I got a problem :/ I got a CSS thingy thast makes the background

  • 0

I got a problem :/
I got a CSS thingy thast makes the background position change on hover. But after i run a function in javascript that changes the hover the CSS one stops working.

This is the function:

function tree() {
var boxfb = document.getElementById('fb_box');
var boxtw = document.getElementById('twitter_box');
var boxsun = document.getElementById('sun_box');
var boxtree = document.getElementById('tree_box');
var btn = document.getElementById('hbtr');
if(boxtree.style.visibility == "hidden") {
    boxtw.style.visibility="hidden";
    boxfb.style.visibility="hidden";
    boxsun.style.visibility="hidden";
    boxtree.style.visibility="visible";
    btn.style.backgroundPosition="-150px -100px";
}
else {
    boxtree.style.visibility="hidden";
    btn.style.backgroundPosition="-150px 0";
}

}

Live at http://enji.se (Press the tree in the top left corner)

  • 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-22T01:10:46+00:00Added an answer on May 22, 2026 at 1:10 am

    Because you’re adding a ‘style’ attribute to your element, anything within this ‘style’ attribute will override any of your predefined CSS settings (it takes priority).
    I this case, “btn.style.backgroundPosition=”-150px 0″;” is overriding your hover style of “-150px -100px”, by adding it directly to the element.

    I’m not sure exactly what you’re going for here, and there’s probably a more simplistic way to do what you’re doing — but I suppose that’s not why you’re here…

    So to fix your problem I would suggest one of two things:
        1) Add/Remove a class using javascript instead of a style attribute
    –OR, as a quick fix-
        2) add ‘!important’ to Line 343 of your stylesheet, like so:

    .tree:hover {
        background-position: -150px -100px !important;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I almost run my first ROR app on HEROKU but I've got problem with
I've got a problem. I made a tag cloud thingy to my website, but
I got a problem like this (this is html/css menu): Eshop | Another eshop
Can anyone help with a small problem. I've got a nice simple CSS dropdown
Good day, I've got a simple CSS question. I'm trying to change a table
Got a problem with a style in IE7. Using this css style table td
I got a problem in IE8(Win XP). Here is my code! My JQuery .hover()
I'm using webview in my xcode javascript refuses to run. has anyone got any
I have got a css problem. http://www.luukratief-design.nl/dump/parallax/index.html I cant get this page to align
i've got a problem with the styling of a select box via css. It

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.