Note that there are some explanatory texts on larger screens.

plurals
  1. POcss how to select a class in another div
    text
    copied!<p>I am trying to make a menu where I show the icon and when i hover over the icon the text will appear. I've got that so far, but I want to change the background color of the text.</p> <pre><code>&lt;div id='menu'&gt; &lt;div id='menuitems'&gt; &lt;div class="item" onclick="loadPage('/')"&gt; &lt;span class="menuIcon"&gt;&lt;img src='/img/layout/icons/home.png'/&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class="item" onclick="loadPage('/pages/settings/')"&gt; &lt;span class="menuIcon"&gt;&lt;img src='/img/layout/icons/settings.png' /&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class="item" onclick="loadPage('/pages/php/')"&gt; &lt;span class='TextMenuItem'&gt;&lt; &amp;#47; &gt;&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="menuText"&gt; &lt;div class="itemtext" onclick="loadPage('/pages/home/')"&gt;Home&lt;/div&gt; &lt;div class="itemtext" onclick="loadPage('/pages/settings/')"&gt;Settings&lt;/div&gt; &lt;div class="itemtext" onclick="loadPage('/pages/php/')"&gt;Projects&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>So if I move over a div with the class <code>item</code> I want to change the color of the div and the div with the class <code>itemtext</code>. Is it possible, in css, to see how many times a class has been used before the one that I hover and based on that number being able to color the background of the <code>itemtext</code> div with the same number or do I have to use javascript?</p> <p>JSFiddle with progress: <a href="http://jsfiddle.net/WszKV/" rel="nofollow">http://jsfiddle.net/WszKV/</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload