大佬教程收集整理的这篇文章主要介绍了如何在菜单打开时更改 Font Awesome 图标的颜色?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我通过检查输入制作了“汉堡菜单”。@H_301_1@
我想知道在菜单展开时要定位什么以及使用什么伪元素来@R_409_6502@很棒的颜色或背景? 如果我可以通过单击页面中的任意位置来关闭此菜单?@H_301_1@
@H_301_1@
.container { wIDth: 300px; margin: auto; } #options li { text-decoration: none; } #options:hover { BACkground-color: #254574; color: white; } .elem { List-style: none; } .show-modal { border-radius: 25px; padding: 5px; } .show-modal:hover { BACkground-color: grey; } .options { position: absolute; BACkground-color: white; cursor: pointer; color: #091f43; line-height: 2rem; height: 2rem; wIDth: 2rem; Font-size: 0.9rem; display: none; margin-top: 15px; } .modifIEr-checkBox:checked~.options { display: flex; flex-direction: column; wIDth: 100px; z-index: 4; } .elem { BACkground-color: white; } .modifIEr-checkBox { opacity: 0; } .card { display: flex; flex-direction: column; Box-shadow: 0 0 1rem 0 rgba(0,0.2); border-radius: 5px; BACkground: inherit; margin-bottom: 2rem; position: relative; &::before { content: ""; position: absolute; BACkground: inherit; z-index: -1; top: 0; left: 0; right: 0; bottom: 0; Box-shadow: inset 0 0 2000px rgba(255,255,0.5); filter: blur(10pX); margin: -20px; } } .header-card { padding: 0.8rem 1rem 0.5rem 1rem; display: flex; justify-content: space-between; align-items: center; border-bottom: $border; } .author { display: flex; Font-weight: bold; Font-size: 0.94rem; color: #091f43; } .date { display: flex; Font-size: 0.75rem; color: #0000007e; } .content { Font-size: 0.94rem; display: flex; padding: 1rem 1rem 1.15rem 1rem; } .img-card { position: relative; display: inline-block; img { display: block; wIDth: 100%; object-fit: contain; } } .flex-right { display: flex; justify-content: space-between; align-items: center; } .fa-tag { margin-right: 0.4rem; } .tag { cursor: default; Font-size: 0.75rem; padding: 0.3rem 0.8rem; margin-right: 15px; Font-weight: bold; text-transform: cAPItalize; BACkground-color: blue; color: white; Box-shadow: 12px 12px 16px 0 rgba(0,0.112),-8px -8px 12px 0 rgba(149,142,216,0.057); border-radius: 50px; } .likebar { display: flex; justify-content: space-between; }
@H_419_11@<link href="https://cdnjs.cloudFlare.com/AJAX/libs/Font-awesome/5.15.3/CSS/all.min.CSS" rel="stylesheet" /> <div class="container"> <div class="card"> <div class="header-card"> <div class="column"> <p class="author">auteur</p> <p class="date">date</p> </div> <div class="flex-right"> <p v-if="tag" class="tag"> <i class="icon-tag fas fa-tag"></i>tag </p> <div class="modifIEr-toggle"> <input type="checkBox" name="toggle" ID="modifIEr-checkBox-1" class="modifIEr-checkBox" /> <label for="modifIEr-checkBox-1" class="modifIEr-toggle"> <i class="show-modal fas fa-ellipsis-h"></i> </label> <ul class="options"> <li class="elem">ModifIEr</li> <li class="elem">Supprimer</li> </ul> </div> </div> </div> </div> </div>
@H_419_11@
@H_301_1@
在 jsFiddle 上查看@H_301_1@
CSS
.fas:hover {
BACkground-color: #000;
color: #fff;
}
JS
var ico = document.getElementsByClassName("fa-ico")[0]
ico.addEventListener('click',function () {
this.style.color = "red"
})
e.target
示例
var container = document.getElementsByClassName("container")[0]
container.addEventListener('click',function (E) {
if(e.target.className === "container") {
this.style.display = "none";
}
})
,
试试这个
.elem{BACkground-color: red;padding:3px;text-align:center;color:green;}
要更改图标颜色,请使用 color:<color-name>;
因为是基于字体的
以上是大佬教程为你收集整理的如何在菜单打开时更改 Font Awesome 图标的颜色?全部内容,希望文章能够帮你解决如何在菜单打开时更改 Font Awesome 图标的颜色?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。