Hovering Over An Image Changes Html Background
Basically: div:hover { body{ background-image:(bg.png); } } This is logical code, I know it does not work, but its the best how I can show you my problem.
Solution 1:
Well what your trying to accomplish cannot be achieved that way using Css only, You can do it using jquery like this
$("#someDiv").hover(function(){
$("body").css("background-image", "url('image_url')")
});
Solution 2:
In css ,You can not do this as "body" is parent element to "div" and it should come next to the element hovered to use the for format like
firstelement:hoversecond_element {/*styles*/}
you can use jquery to achieve it
$("div").hover(function(){
$("body").css("background", "url('url_of_image_here')")
});
or javascript
elem = document.getElementById("ID");
elem.addEventListener("mouseout", function(){
document.getElementsByTagName("body")[0].style.backgroundImage="url()";
});
Post a Comment for "Hovering Over An Image Changes Html Background"