html - 将多个 HTML 元素合并为一个 CSS 类以显示选定状态
问题描述
我对 css 的东西比较陌生。I have ul
with a couple of li
elements each li
element contain SVG
and p
element.when that li is selected I want to add styling to those li
and SVG,p
element
<ul>
<li>
<a href="#">
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="22" height="22" viewBox="0 0 24 24"
style="fill:#83868F">
<path </svg> Infor 2</a> </li> <li class>
<a href="#">
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="22" height="22" viewBox="0 0 24 24"
style="fill:#83868F">
<path </svg> Infor 1
</a>
</li>
</ul>
我如何使用一个类来实现这一点?另外,我想知道如何将类动态应用于我的角度组件
解决方案
假设您将“ active
”类添加到您的<ul>
元素中:
ul.active{
//add style here
}
ul.active li{
//add li style here
}
ul.active svg{
//add svg style here
}
ul.active p{
//add p style here
}
推荐阅读
- php - 从表单中获取 ip 地址
- javascript - 如何停止 JavaScript 在不包含查询元素的页面上运行?
- string - 第一个重复字符 | 运行
- sparql - 查找 DBPedia 资源的所有 Wikilinks,其中 Wikilinks 共享相同的主题
- datetime - 如何破译这个 8 位数的时间戳?
- django - 在 django restframework 中覆盖查询集时如何从数据库中过滤产品
- android - 在主活动中侦听首选项按钮单击
- java - Java中的手动依赖注入(没有spring boot)
- sql - 用相同数据集中的相似行值替换缺失值(无连接)
- html - 自定义由 v-for 指令呈现的项目样式