Getting 2 divs to change colour when hovering over 1 div

Neb9

I'm trying to get the background colour of .skin-1 and .roll-1 to change colour when the mouse rolls over .roll-1, I believe I've got issues with my css selector targeting. I'm using .roll-1:hover ~ .skin-1{background: #ed008c;} to change both and this worked before I put the li's in separate ul's

Can someone let me know what i'm doing wrong.

<style>
.catlevel ul {list-style: none;}
.catlevel ul li{float: left;}
.catlevel ul li img{padding:10px;}
.catlevel li a {display: block;}
.mypad{margin:0 12px 10px 0;}
.endpad{margin:0 0 10px 0;}
.rollpad{margin: 0 10px 0 0;}
.dock-menu {width: 100%;padding: 0;margin: 0;text-align: center;font-size: 0;}
.dock-menu-list {display: inline-block;padding: 0;list-style: none;}
.dock-menu-list li {display: inline-block;margin: 0;padding: 0;min-width: 75px;min-height: 75px;}
.dock-menu-list li img {display: inline-block;cursor: pointer;padding:10px}

.roll-1, .skin-1 {background: #baa3d3;-webkit-box-shadow: 0 0 3px rgba(153,153,153,0.25);box-shadow: 0 0 3px rgba(153,153,153,0.25);transition: background 1s;-webkit-transition: background 1s;}

.roll-1:hover {background: #ed008c;}
.roll-1:hover ~ .skin-1{background: #ed008c;}
</style>

<div id="mContainer">
<div id="categorylist">
<div id="catgoldspot"></div>
<div id="catgoldspot"></div>
<div class="catlevel">
<div class="dock-menu">
<ul class="dock-menu-list">
    <li class="roll-1 rollpad"><a href="#"><img src="main.jpg" /></a></li>
</ul>
</div>
</div>
<div class="catlevel">
<ul class="nopad">
    <li class="skin-1 mypad"><a href="#"><img src="test.jpg" /></a></li>

</ul>
</div>
</div>
</div>
demo

.roll-1:hover ~ .skin-1{background: #ed008c;} // Here you select on hover all roll-1 that contains slin-1

From your html here are no roll-1 that contains skin-1.

Source : http://www.w3schools.com/cssref/css_selectors.asp

As solution i can suggest use jquery script :

$('.roll-1').hover(function(){
    $('.skin-1').css('background', '#ed008c');
}, function(){
    $('.skin-1').css('background', '#baa3d3');
});

Example : http://jsfiddle.net/p0y49hk9/1/

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to change color of element when hovering over another element?

changed menu bar colour and now can no longer see menu when hovering over button

three.js - change colour of object when hovering over it

Change colour of svg paths when hovering over it's container

div rollover getting child divs to change color

How to change class of separate div when hovering over link using JQuery

Is there a way to change a target div's text when hovering over other div's using css only?

Custom Elements are not getting marked when hovering over them with Chrome DevTools

Change CSS of li class when hovering over a class

Displaying button when hovering over div in TailwindCSS

Can I change the background-colour of an element, when hovering over another?

Change Color of Icon When Hovering Over Adjacent Text With jQuery

CSS div that appears when hovering on anchor; keeping it visible while hovering over div

Change BODY background color when hovering over a table cell

How to display a div when hovering over another div

Javascript change colour of divs, and then colour of the div's focus

Hovering over divs not affecting div

Changing divs when hovering over a different div

Add divs on top of an div, when hovering

Change colors of spans when hovering parent div

Div over 2 other divs?

Change image when hovering over a list of text

How to change css of one class when hovering over another?

Change the colour of a triangle div over time

Hovering over 1 div to change content in another

Change color of icon when hovering over div in which it is contained

How to change icon colour when hovering on enclosing div container

Change the Brightness of a div when hovering over another div

Change image when hovering over text with JavaScript