简体   繁体   English

要突出显示鼠标悬停在相应项目上的图像。

[英]Want to highlight an image on mouseover on corresponding item.

<html>
    <head>
        <link rel="stylesheet" type="text/css" href="troll.css">
    </head>
    <body>

        <div id="bad">
            <!--change start here-->
            <p>
                <img src="image1.jpg"  id="boa">
                <span class="bob">Flatkit</span>
            </p>
                <!--button2-->        
                <img src="right.jpg"  onclick="buttonSec()" id="buttnsec">
                <p class="boc" >Main</p>

            <!--change ends here-->
            <ul class="parent" onclick="mangoGrape()"><img src="img.jpg">Dashboard</ul>

            <ul class="parent" onclick="mangoGrape(this)"><img src="img1.jpg">Apps
                <div id="pappaya">
                <li class="apple"> <a href="#">Inbox</a></li>
                 <li class="apple"><a href="#">Condact</a></li>
                 <li class="apple"><a href="#">Calendar</a></li>
                </div>
            </ul>
             <ul class="parent" onclick="mangoGrape(this)"><img src="img2.jpg">Layout
                <div id="pappayas">
                 <li class="orang"><a href="#">header</a></li>
                 <li class="orang"><a href="#">aside</a></li>
                 <li class="orang"><a href="#">footer</a></li>
                </div>
            </ul>
             <ul class="parent" onclick="mangoGrape()"><img src="img3.jpg">Widjet</ul>

        </div>


        <script>
            window.mangoGrape = function(elm){
              var invisible = false;
              if(elm){
                invisible = elm.querySelector("li").style.display == "none";
              }
              document.querySelectorAll('li').forEach(function(node){
                node.style.display="none";
              })
              if(invisible){
                elm.querySelectorAll("li").forEach(function(node){
                  node.style.display="block";
                })
              }
            }
        </script>
    </body>
</html>

associated CSS; 相关的CSS;

li a{
    text-decoration: none;
}
.parent li{
    list-style-type: none;
    display: none;
    text-decoration: none;
}
#bad .parent{
    cursor: pointer;
    font-family: sans-serif;
    line-height: 200%;


}
#bad{

    background-color: #023b3b;
        width: 15%;

    height: 100%;
    color: white;
}
/* #bad .parent {
    height: 100%;
    width: 100%;
    display: block;
    cursor: pointer;
    line-height: 3%;
    height: 30px;
    background: #023b3b;
    color: white;
    text-align: center;
}*/
#pappaya {
    background-color:#339933;
    width: 180%;
    margin-left: -28%;
    padding-left: 38%;
    padding-right: 40%;
    width: 50%;
    /*text-align: center;
    margin-right:122%;*/
}
 #pappayas {
        /*background-color:#339933;
         width: 100%;
    margin-left: -50%;
    padding-left: 50%;*/
    background-color:#339933;
    width: 180%;
    margin-left: -28%;
    padding-left: 38%;
    padding-right: 40%;
    width: 50%;
    }
#pappaya li:hover{
    background-color: #122112;
    color: white;
    width: 184%;
    margin-left: -75%;
    padding-left: 70%;
}
#pappaya li a:hover{
    color: white;

}
#pappayas li:hover{
    /*text-align: center;*/
    background-color: #122112;
    color: white;
    width: 184%;
    margin-left: -75%;
    padding-left: 70%;
}
#pappayas li a:hover{
    color: white;

}

#bad{

    background-color: #023b3b;
        width: 15%;

    height: 100%;
    color: white;
}
#bad .parent:hover
{
    background-color: #122112;
    color: white;
    width: 78%;
}
#bad ul:hover{
    background-color: #122112;}
#bad .parent:hover ~ .parent img{
    width: 13%;
    height: 3%;
}

/*new setup*/
#boa{
    height: 5%;
    width: 20%;
    float: left;

}
.bob{
    text-indent: 200%;
    line-height: 210%;
    font-size: 150%;
    font-family: sans-serif;
    color: white;
    font-weight: bold;

}
#buttnsec{
     margin-left: 94%;
        width: 10%;
        hyphens: 20%;
}
.boc{
    text-indent: 4%;
    color : white;
    font-size: 83%;
    font-family: sans-serif;

    font-weight: normal;
}
.parent img{
    float: left;
    width: 15%;
    height: 3%;
    margin-left: -12%;
    margin-right: 20%;
}
/*#bad .parent :hover{
     background: #122112;
}*/

In this code on mouseover on an item the images below the corresponding item become smaller, instead of that I want to reduce the size of the image of the item the mouse pointer currently stands/focused. 在此代码上,将鼠标悬停在某个项目上时,对应项目下的图像会变小,而不是我要减小鼠标指针当前站立/聚焦的项目图像的大小。 view current output 查看当前输出

Try changing 尝试改变

#bad .parent:hover ~ .parent img{
    width: 13%;
    height: 3%;
}

to

#bad .parent:hover img{
    width: 13%;
    height: 3%;
}

Now, it'll work if you just hover over the menu item. 现在,将鼠标悬停在菜单项上即可使用。

Look at this: 看这个:

#bad .parent:hover ~ .parent img{
    width: 13%;
    height: 3%;
}

to: 至:

#bad .parent:hover > img {
    width: 13%;
    height: 3%;
}

Working example here 这里的工作示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 图像地图鼠标悬停突出显示 - Image Map Mouseover highlight 鼠标悬停时突出显示图像的一部分 - Highlight parts of an image on mouseover 画廊。 显示与点击对应的div <li> 项目。 Java脚本 - Gallery. Display divs corresponding to clicked <li> item. Javascript 高亮显示当前页面菜单项。 选择子菜单项时也突出显示主菜单项 - Highlight current page menu item. Also highlight main menu item when sub menu item is selected 想要在JavaScript中将值随机索引设置为项目并将对应的图像设置为tempImages - want to Set Value random index to item and corresponding image to tempImages in javascript 如何在鼠标悬停时突出显示不同div中的文本和图像 - How to highlight text and image in different divs on mouseover 突出显示活动 HTML 部分的相应菜单项 - Highlight the corresponding menu item of active HTML section 我想在每个项目的for循环中添加计数器。(vue.js) - I want to add counter in for loop in each item.(vue.js) 鼠标悬停在网页上的文本时突出显示映射图像的部分 - Highlight Section of Mapped Image when Mouseover Text on Webpage 尝试连接图像的鼠标悬停以在 javascript 文件中突出显示其下方的文本链接 - Trying to connect the mouseover of an image to highlight a text link below it in a javascript file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM