• <tfoot id='yBRg2'></tfoot>
        <bdo id='yBRg2'></bdo><ul id='yBRg2'></ul>
      <legend id='yBRg2'><style id='yBRg2'><dir id='yBRg2'><q id='yBRg2'></q></dir></style></legend>

      1. <i id='yBRg2'><tr id='yBRg2'><dt id='yBRg2'><q id='yBRg2'><span id='yBRg2'><b id='yBRg2'><form id='yBRg2'><ins id='yBRg2'></ins><ul id='yBRg2'></ul><sub id='yBRg2'></sub></form><legend id='yBRg2'></legend><bdo id='yBRg2'><pre id='yBRg2'><center id='yBRg2'></center></pre></bdo></b><th id='yBRg2'></th></span></q></dt></tr></i><div id='yBRg2'><tfoot id='yBRg2'></tfoot><dl id='yBRg2'><fieldset id='yBRg2'></fieldset></dl></div>
      2. <small id='yBRg2'></small><noframes id='yBRg2'>

        更改所有元素的不透明度,除了悬停的元素

        时间:2023-11-01
        • <bdo id='IY92I'></bdo><ul id='IY92I'></ul>
            <tbody id='IY92I'></tbody>
            <legend id='IY92I'><style id='IY92I'><dir id='IY92I'><q id='IY92I'></q></dir></style></legend>
            <i id='IY92I'><tr id='IY92I'><dt id='IY92I'><q id='IY92I'><span id='IY92I'><b id='IY92I'><form id='IY92I'><ins id='IY92I'></ins><ul id='IY92I'></ul><sub id='IY92I'></sub></form><legend id='IY92I'></legend><bdo id='IY92I'><pre id='IY92I'><center id='IY92I'></center></pre></bdo></b><th id='IY92I'></th></span></q></dt></tr></i><div id='IY92I'><tfoot id='IY92I'></tfoot><dl id='IY92I'><fieldset id='IY92I'></fieldset></dl></div>

              <tfoot id='IY92I'></tfoot>

                <small id='IY92I'></small><noframes id='IY92I'>

                  本文介绍了更改所有元素的不透明度,除了悬停的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想知道是否有一种方法可以降低所有li"的不透明度(悬停时)除了我实际悬停的那个?类似于这张图片的东西:

                  I wonder if there is a way to lower opacity (on hover) to all of the 'li's' except the one I'm actually hovering? Something similar to this picture:

                  .main-navigation { 
                      margin: 0;
                      padding: 20px 0px 25px;
                      list-style: none;
                      background-color: #ffffff;
                      text-align: center;
                      display:block;
                      font-size:1.1em;    
                  }
                  .main-navigation li.hvr a.lvl1:link,
                  .main-navigation li.hvr a.lvl1:visited 
                  {
                  	display: block;
                  	padding: 5px 2px 5px 3px;
                  	color: #000;
                  	text-decoration: none;
                      text-align:center;
                  }
                  .main-navigation li.hvr a.lvl1.active { 
                      background: #eeeeee; 
                      color:#000000;
                  }
                  .main-navigation li.hvr a.lvl1:hover
                  {
                  	background-color: #E6E6E6;
                      color:#666666;
                  } 
                  .main-navigation li.hvr { 
                  	float: left; 
                  	position: relative;
                      width:191px;
                      margin:0;
                      font-family: 'Open Sans', sans-serif;
                  }
                  .main-navigation li.hvr:hover { 
                  	background-color: #E6E6E6;
                  }
                  .main-navigation ul { 
                  	display: none;
                  	position: absolute;
                  	top:100%;
                  	left: 0;
                  	z-index: 9999;
                  	background-color: #777;
                  	margin: 0;
                  	padding: 0;
                  	min-width:100%;
                  	text-align:left;
                  }
                  .main-navigation li.hvr:hover ul { display: block; }
                  .main-navigation li.hvr ul li { 
                  	margin: 0;
                  	padding: 0;
                  	list-style: none;
                  }
                  .main-navigation li.hvr ul li a:link,
                  .main-navigation li.hvr ul li a:visited
                  {
                  	display: block;
                  	padding: 5px 20px;
                  	color: #fff;
                      text-align: center;
                  }
                  .main-navigation li.hvr ul li a:hover,
                  .main-navigation li.hvr ul li a:active
                  {
                      display: block;
                      padding: 5px 20px;
                      color: #fff;
                      background-color:#cccccc;
                  }

                  <ul class="main-navigation clearfix">
                      <li class="hvr ">
                          <a class="lvl1 active" href="">Title 1</a>
                          <ul>
                              <li><a href="">Sub title 1</a></li>
                              <li><a href="">Sub title 2</a></li>
                              <li><a href="">Sub title 3</a></li>
                          </ul>
                      </li>
                      <li class="hvr ">
                          <a class="lvl1" href="">Title 2</a>
                          <ul>
                              <li><a href="">Sub title 1</a></li>
                              <li><a href="">Sub title 2</a></li>
                              <li><a href="">Sub title 3</a></li>
                          </ul>
                      </li>
                      <li class="hvr ">
                          <a class="lvl1" href="">Title 3</a>
                          <ul>
                              <li><a href="">Sub title 1</a></li>
                              <li><a href="">Sub title 2</a></li>
                              <li><a href="">Sub title 3</a></li>
                          </ul>
                      </li>
                      <li class="hvr ">
                          <a class="lvl1" href="">Title 4</a>
                          <ul>
                              <li><a href="">Sub title 1</a></li>
                              <li><a href="">Sub title 2</a></li>
                              <li><a href="">Sub title 3</a></li>
                          </ul>
                      </li>
                  </ul>

                  推荐答案

                  你使用 CSS 降低了所有元素的不透明度,除了悬停的元素.

                  You lower the opacity of all alements except the hovered one with CSS.

                  重点是在父元素(ul)悬停时降低所有<li>元素的不透明度,并在悬停<像这样的code>li元素:

                  The point is to lower the opacity of all <li> elements when the parent (ul) is hovered and to reset the opacity to 1 on the hovered li element like this :

                  ul:hover li { opacity:0.5; }
                  ul li:hover { opacity:1; }
                  

                  这是一个简单的演示:

                  li{
                    float:left;
                    width:33.33%;
                    line-height:50px;
                    background:grey;
                    list-style-type:none;
                  }
                  ul:hover li{
                    opacity:0.5;
                  }
                  ul li:hover{
                    opacity:1;
                  }

                  <ul>
                    <li>item</li>
                    <li>item</li>
                    <li>item</li>
                  </ul>

                  这篇关于更改所有元素的不透明度,除了悬停的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇::hover (鼠标离开时)的反义词是什么? 下一篇:使用带有 HTML 图像映射的 JQuery 悬停

                  相关文章

                  • <bdo id='uxJsO'></bdo><ul id='uxJsO'></ul>
                  <tfoot id='uxJsO'></tfoot>

                1. <i id='uxJsO'><tr id='uxJsO'><dt id='uxJsO'><q id='uxJsO'><span id='uxJsO'><b id='uxJsO'><form id='uxJsO'><ins id='uxJsO'></ins><ul id='uxJsO'></ul><sub id='uxJsO'></sub></form><legend id='uxJsO'></legend><bdo id='uxJsO'><pre id='uxJsO'><center id='uxJsO'></center></pre></bdo></b><th id='uxJsO'></th></span></q></dt></tr></i><div id='uxJsO'><tfoot id='uxJsO'></tfoot><dl id='uxJsO'><fieldset id='uxJsO'></fieldset></dl></div>

                    <small id='uxJsO'></small><noframes id='uxJsO'>

                      <legend id='uxJsO'><style id='uxJsO'><dir id='uxJsO'><q id='uxJsO'></q></dir></style></legend>