jquery - jquery覆盖我的css颜色
问题描述
我做了一个菜单,它工作完美,直到我添加 jquery 链接如下
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.css">
<script src="http://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.js"></script>
添加这些链接时,我的菜单按钮颜色将变为灰色而不是黑色(在添加这些链接之前)因为我需要在 Jquery 中使用移动“swipeleft”,所以我无法删除这些链接,对我的问题有任何想法吗?谢谢求助!!
以下是我的代码,它的菜单按钮颜色是黑色
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
*{box-sizing: border-box}
body{
font-family:"Microsoft JhengHei",Georgia,Serif;
}
/* Style the tab content */
.tabcontent {
/* float: right;*/
padding: 0px 12px;
/* border: 1px solid #111;*/
text-align:center;
width: 100%;
border-left: none;
/* height: 300px;*/
}
.sidenav {
height: 100%;
width:0;
position: fixed;
z-index: 2;
top: 0;
left: 0;
background-color: #111;
overflow-x: hidden;
transition: 0.5s;
padding-top: 60px;
}
.sidenav button { /*set the text in button*/
text-decoration: none;
border: 0px;
font-size: 25px;
color: #818181;
display: block;
transition: 0.3s;
}
.sidenav a { /*set the text in button*/
padding: 8px 8px 8px 32px;
text-decoration: none;
border: 0px;
font-size: 25px;
color: #818181;
display: block;
transition: 0.3s;
}
.sidenav button:hover {
color: #f1f1f1;
}
.sidenav a:hover {
color: #f1f1f1;
}
.sidenav .closebtn { /*x apprearance*/
position: absolute;
top: 0;
right: 25px;
font-size: 50px;
margin-left: 50px;
}
.button{
background-color: #111;
height: 10%;
width: 100%;
text-align: left;
font-weight: bold;
font-family:"Microsoft JhengHei",Georgia,Serif;
}
@media screen and (max-height: 450px) {
.sidenav {padding-top: 15px;}
.sidenav a {font-size: 18px;}
}
/*following is for my slide attribute*/
.fade {
-webkit-animation-name: fade;
-webkit-animation-duration: 1.5s;
animation-name: fade;
animation-duration: 1.5s;
}
@-webkit-keyframes fade {
from {display: block;}
to {margin: 0;}
}
@keyframes fade {
from {opacity: .4}
to {opacity: 1}
}
</style>
</head>
<body>
<div id="mySidenav" class="sidenav" >
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×
</a>
<button class="button"class="tablinks" onclick="open_more(event,
'main_page')" id="defaultOpen"> 首頁</button>
</div>
<span style="font-size:30px;cursor:pointer" onclick="openNav()">☰
</span>
<script>
// Get the element with id="defaultOpen" and click on it
document.getElementById("defaultOpen").click();
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
}
</script>
</body>
</html>
解决方案
例如,您可以使用!important
由 JQuery 更改的属性例如:
background-color: red !important;
另一种可能性是你改变你的类名。
第一个更容易,第二个更好(因为!important
不好)
推荐阅读
- python - 如何从 flask-SQLAlchemy 查询 SQL 视图
- javascript - Finnesing fullcallendar; 列表视图序数
- r - 尝试连接到 R 上的 mongodb 时找不到合适的服务器
- r - 如何计算两列之间的时间差?
- python - 如何在 PySimpleGUI 中一次将多个窗口全屏显示
- javascript - 多个可选捕获组的正则表达式模式
- spring-cloud-stream - Spring Cloud Stream中如何添加或调整文件供应商的配置
- python - 从标准数组中删除选定的值 - mongodb + python
- jbpm - 具有正确所有者的 JBPM 7.44 任务返回“无当前匹配”
- python - SQL Server rowversion 数据类型的 Python 字节到字符串