【发布时间】:2019-07-24 23:34:51
【问题描述】:
我尝试了我所知道的一切,但我的汉堡菜单图标就是不想向右移动...有谁知道到底是什么让它留在了左边?
我也在使用 SemanticUI。
这是我的代码:https://jsfiddle.net/657pxedq/5/
HTML:
<div id="navbar">
<div class="openbtn" onclick="openNav()"><i class="bars icon"></i></div>
</div>
<script>
function openNav() {
document.getElementById("mySidebar").style.width = "250px";
document.getElementById("main").style.marginRight = "250px";
document.getElementById("dimmer").style.display = "block";
}
function closeNav() {
document.getElementById("mySidebar").style.width = "0";
document.getElementById("main").style.marginRight = "0";
document.getElementById("dimmer").style.display = "none";
}
</script>
<script>
window.onscroll = function() {myFunction()};
var navbar = document.getElementById("navbar");
var sticky = navbar.offsetTop;
function myFunction() {
if (window.pageYOffset >= sticky) {
navbar.classList.add("sticky")
} else {
navbar.classList.remove("sticky");
}
}
</script>
CSS:
.openbtn {
font-size: 20px;
cursor: pointer;
color: #744a84;
padding: 10px 15px;
border: none;
background-color: transparent;
right: 0;
justify-content: right;
float: right;
text-align: right;
}
#navbar {
position: fixed;
overflow: hidden;
background-color: transparent;
display: flex;
justify-content: right;
width: 100%;
z-index: 2;
text-align: right;
}
.sticky {
position: fixed;
top: 0;
width: 100%;
}
(uggh,由于代码太多,Stackoverflow 想让我添加更多细节……但我不知道该说些什么)
提前致谢!
【问题讨论】:
-
它在我的右边,自从发布后你更新了吗?
-
真的吗?我看到它还在左边...prntscr.com/msm1nf --- 哦,也许我的标题不够清楚...我的意思是汉堡菜单图标
-
哇,好吧...我现在检查了不同的浏览器,在 Firefox 中它似乎可以工作,但在 Opera 和 Chrome 中却不行...非常有趣,谢谢
标签: html css position semantic-ui hamburger-menu