简体   繁体   English

我怎样才能把这个css给特定的li类?

[英]How can i give this css to specific a li class?

I am trying to give the css bellow to a li or span class but i can't really.我正在尝试将 CSS 波纹管提供给 li 或 span 类,但我真的做不到。 Can you help me with that?你能帮我解决这个问题吗?

.nav--icons ul li a.is-active {
  color: #fff;
  background-color: #000;
}
.nav--icons ul li a:hover span,
.nav--icons ul li a.is-active span {
  opacity: 1;
  max-width: 40px;
  transform: translate3d(0, 0, 0);
}

Or we can say i wan't that list item to be hover active as default.或者我们可以说我不希望该列表项默认为悬停活动。 The code is that;代码是这样的;

           <a class="selected1" href="#home">
            <svg class="icon icon-home" viewBox="0 0 24 24" width="24" height="24">
<path fill="currentColor" d="M21.6 8.2l-9-7c-0.4-0.3-0.9-0.3-1.2 0l-9 7c-0.3 0.2-0.4 0.5-0.4 0.8v11c0 1.7 1.3 3 3 3h14c1.7 0 3-1.3 3-3v-11c0-0.3-0.1-0.6-0.4-0.8zM14 21h-4v-8h4v8zM20 20c0 0.6-0.4 1-1 1h-3v-9c0-0.6-0.4-1-1-1h-6c-0.6 0-1 0.4-1 1v9h-3c-0.6 0-1-0.4-1-1v-10.5l8-6.2 8 6.2v10.5z"></path>
            </svg>
            <span class="selected2">Home</span>
          </a>
        </li>

If you want to give the style to every svg underneath a li selector and to every span underneath a li selector, you may write:如果您想为 li 选择器下的每个svg和 li 选择器下的每个span赋予样式,您可以编写:

li svg, li span {
    color: #fff;
    background-color: #000;
}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM