[英]Django: Change font-color inside a javascript-function
Good day,再会,
the font-color of my html-body is changed via a css-file with following code:我的 html-body 的字体颜色通过带有以下代码的 css 文件进行更改:
body {
background-color: #6d6a6a;
color: white;
}
Now I've included a Bootstrap-Popover...现在我已经包含了一个 Bootstrap-Popover ......
<button type="button" class="btn btn-sm btn-danger" data-toggle="popover" title="Popover title" data-content="And here's some amazing content. It's very engaging. Right?">Click to toggle popover</button>
...and the necessary script... ...以及必要的脚本...
<script>
$(function () {
$('[data-toggle="popover"]').popover()
})
</script>
But because of my css-file, some parts of text inside my popver (the "title" to be exact) are also rendered in white, I'm really new to javascript, so is it possible - and when it's possible?但是由于我的 css 文件,我的 popver 中的某些文本部分(确切地说是“标题”)也呈现为白色,我对 javascript 真的很陌生,所以有可能 - 什么时候有可能? what would be the best solution - to change my font-color inside my Popover to black?
最好的解决方案是什么 - 将 Popover 内的字体颜色更改为黑色?
Thanks to all of you!感谢大家!
If your css doesn't change dynamically then use only css如果您的 css 没有动态变化,则仅使用 css
.popover .popover-content,.popover .popover-title {
color: red;
}
But if u are changing your body dynamically then u can add class to your popover.但是如果你动态地改变你的身体,那么你可以将 class 添加到你的弹出窗口中。 Popover has always
.popover
as class name so u can Popover 始终
.popover
作为 class 名称,因此您可以
$(document).ready(function () { $(function () { $('[data-toggle="popover"]').popover() }); }); function popchange(){ setTimeout(function () { $(".popover").addClass('popover-danger'); }, 10); }
.popover-danger { color: red; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/> <button type="button" class="btn btn-sm btn-danger" data-toggle="popover"onclick="popchange()" title="Popover title" data-content="And here's some amazing content. It's very engaging. Right?">Click to toggle popover</button>
add class to your popover and then add the new css rule for that class:将 class 添加到弹出窗口,然后为该 class 添加新的 css 规则:
.popover-class {
color: black;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.