Note that there are some explanatory texts on larger screens.

plurals
  1. POGet all not hovered elements and do something with them
    primarykey
    data
    text
    <p>My problem is probably quite simple, but somehow I can’t get it fixed. In a group of objects with one object hovered over, I’d like the hovered object to remain unchanged, but all others are supposed to change.</p> <p>To be more specific: I have an unordered list of menu-items. Whenever I hover over one of them, all the other items are supposed to become smaller. When I "unhover" the item they should change back again.</p> <p>I found this post, but it’s answers didn’t work for me: <a href="https://stackoverflow.com/questions/9685073/set-style-for-not-not-hovered-elements-only">Set style for not not hovered elements only</a></p> <p>This is what I tried so far:</p> <pre><code>/*This is the default size*/ #navigation ul li a { font-size: 14px; } /*When the list is hovered, change font-size (does’nt work)*/ #navigation ul:hover { font-size: 13px; } /*When the a menu-item is hovered change it’s font-size back to default*/ #navigation ul li a:hover { font-size: 14px; } </code></pre> <p>This is one of the answers I found in the post I mentioned. It would be great if it could be done that simply with plain CSS. But it’s not working. Did I do something wrong?</p> <p>I also tried something with jQuery, although I’m not an expert.</p> <pre><code>for(var i=1; i &lt;= anzahlNavipunkte; i++) { var naviId = "navi" + i; // id name for every menu-item var currentMenuItem = "#navigation li:nth-child(" + i + ") a"; $(currentMenuItem).attr('id', naviId); // gives the current menu-item a specific id $('#navigation li a').hover(function() { var hoveredId = $(this).attr("id"); // get the id of of the hovered element $('#' + hoveredId).hover(function() { console.log(hoveredId); $('#' + hoveredId).css('font-size', '14px'); // hovered element gets default font-size $('#navigation ul').css('font-size', '13px'); // other elements change to 13px }, function() { $('#navigation ul').css('font-size', '14px'); // other elements change back }) }); }; </code></pre> <p>It doesn’t work, either. Probably because it’s the same approach as with the plain CSS-solution. Can anybody help me out?</p> <p>I hope my explanation is understandable. If there are questions left please ask.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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