现在我有了a
将按钮的颜色更改为蓝色的元素...我想做的很简单,但是我对CSS的了解不足。
我想做另一堂课而不删除当前课,我该怎么做?
代码:
<div>
<div class='btn btn-success'>
<a href='javascript:Addlog(" + id + ");' role='button'>
<i class='fa fa-pencil-square-o'></i> Complete</a>
</div></div>
CSS:
a, .a {
color: #003F8F;
}
a:hover, a:focus {
color: #23527c;
text-decoration: underline;
}
我想添加类似以下内容:
a, .a {
color: white;
}
a:hover, a:focus {
color: white;
text-decoration: none;
}
但是在不删除当前CSS的情况下不影响已经存在的代码
然后使用CSS类,您可以动态地从任意元素中添加或删除CSS类。
.light {
color: white;
}
a.light:hover,
a.light:focus {
color: white;
text-decoration: none;
}
JS示例,假设您的链接具有class="color-change-button"
:
document.querySelector('.color-change-button').addEventListener('click', function() {
this.classList.toggle('light');
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句