gpt4 book ai didi

javascript - 将 jscolor 类添加到 Bootstrap 导航栏

转载 作者:太空宇宙 更新时间:2023-11-04 01:47:29 26 4
gpt4 key购买 nike

我正在尝试使 boootstrap 导航栏与 jscolor 一起工作,就像下面这个按钮一样。

<script src="https://cdnjs.cloudflare.com/ajax/libs/jscolor/2.0.4/jscolor.min.js"></script>
<button
class="jscolor {valueElement:null,value:'333'}"
style="border:1px solid black">
Color
</button>

这是我试图与 jscolor 连接的导航栏:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jscolor/2.0.4/jscolor.min.js"></script>
<script src="jscolor.js"></script>

<nav class="navbar navbar-inverse navbar-fixed-top jscolor {valueElement:null,value:'333'}">

最佳答案

希望这会有所帮助,z-index 是必需的,这样导航栏就不会与颜色选择器重叠。

var nav = document.getElementById("navbar");
var navColor = document.getElementById("nav-color");

nav.addEventListener("click", function(){
navColor.jscolor.show();
});
#navbar {
z-index: 0;
cursor: pointer;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jscolor/2.0.4/jscolor.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jscolor/2.0.4/jscolor.min.js"></script>

<input id="nav-color" class="jscolor {styleElement:'navbar',value:'333'}" type="hidden">
<nav id="navbar" class="navbar navbar-inverse navbar-fixed-top ">
</nav>

关于javascript - 将 jscolor 类添加到 Bootstrap 导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44182423/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com