我讨厌按下我的运气寻求帮助,但无论如何我都去了 -
我从w3schools.com获得了这段代码,但无法弄清楚如何在HTML代码中将OPEN这个词变成另一种颜色。它目前是黑色的,我希望它是白色的。我改变了其他颜色,因为我的实际页面有黑色背景。对不起,代码太长了,我觉得太好了太多了。这是我目前的代码:
HTML
<div id="mySidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<a href="#">About</a>
<a href="#">Services</a>
<a href="#">Clients</a>
<a href="#">Contact</a>
</div>
<p>Click on the element below to open the menu</p>
<span style="font-size:30px;cursor:pointer" onclick="openNav()">☰ open</span>
<script>
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
}
</script>
CSS
body {
font-family: "Lato", sans-serif;
}
.sidenav {
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #DD0;
overflow-x: hidden;
transition: 0.5s;
padding-top: 60px;
}
.sidenav a {
padding: 8px 8px 8px 32px;
text-decoration: none;
font-size: 25px;
color: #2707AB;
display: block;
transition: 0.3s;
}
.sidenav a:hover {
color: #818181;
}
.sidenav .closebtn {
position: absolute;
top: 0;
right: 25px;
font-size: 36px;
margin-left: 50px;
}
@media screen and (max-height: 450px) {
.sidenav {padding-top: 15px;}
.sidenav a {font-size: 18px;}
}
感谢您的帮助!
答案 0 :(得分:0)
试试这个
body {
font-family: "Lato", sans-serif;
}
.sidenav {
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #DD0;
overflow-x: hidden;
transition: 0.5s;
padding-top: 60px;
}
.sidenav a {
padding: 8px 8px 8px 32px;
text-decoration: none;
font-size: 25px;
color: #2707AB;
display: block;
transition: 0.3s;
}
.sidenav a:hover {
color: #818181;
}
.sidenav .closebtn {
position: absolute;
top: 0;
right: 25px;
font-size: 36px;
margin-left: 50px;
}
@media screen and (max-height: 450px) {
.sidenav {padding-top: 15px;}
.sidenav a {font-size: 18px;}
}
.opencolor
{
color:tan;
}
&#13;
<div id="mySidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<a href="#">About</a>
<a href="#">Services</a>
<a href="#">Clients</a>
<a href="#">Contact</a>
</div>
<p>Click on the element below to open the menu</p>
<span style="font-size:30px;cursor:pointer;">☰ </span><span style="font-size:30px;cursor:pointer;" class="opencolor" onclick="openNav()">open</span>
<script>
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
}
</script>
&#13;
答案 1 :(得分:0)
如果你正在寻找开放颜色的changin试试这个。
<p>Click on the element below to open the menu</p>
<span style="font-size:30px;cursor:pointer" onclick="openNav()">☰ <font color="red">open</font></span>
或
<p>Click on the element below to open the menu</p>
<span style="font-size:30px;cursor:pointer" onclick="openNav()">☰ <span style="color:blue;">open</span></span>
答案 2 :(得分:0)
在里面拿一个课,为那个班写css。
<span class="foo" onclick="openNav()">☰ open</span>
CSS
.foo{
font-size:30px;
cursor:pointer;
color:#fff;
}
如果您只想更改该条形颜色,请使用该hss
<div onclick="openNav()"><span class="bar">☰</span> open</div>