gpt4 book ai didi

javascript - 难以使用响应式导航插件排列我的导航链接和 Logo

转载 作者:太空宇宙 更新时间:2023-11-03 17:55:22 26 4
gpt4 key购买 nike

我正在使用 http://responsive-nav.com/插件来创建我的导航栏,但遇到了链接和 Logo 水平排列的问题。我目前正在尝试将我的链接 float 到右侧,但它们仍然出现在我图片下方的级别上。有更好的方法吗?

桌面图片:

Desktop Image

移动图片:

Mobile Image

HTML:

<!DOCTYPE HTML>
<html>
<head>
<% include ../partials/head %>
</head>

<body>


<header>
<div id="navigation-container">
<div id="nav-logo">
<a href="/"><img src="images/lvc-logo.png"></a>
</div>
<nav class="nav-collapse" id="navigation-links">
<ul>
<li><a href="/about">ABOUT</a></li>
<li><a href="/events">EVENTS</a></li>
<li><a href="/media">MEDIA</a></li>
</ul>
</nav>
</div>
</header>

<script>
var navigation = responsiveNav(".nav-collapse", {
insert: "before"
});
</script>
</body>
</html>

CSS:

/*! responsive-nav.js 1.0.32 by @viljamis */

#navigation-container {
background-color: #fff;
}

#nav-logo img {

width: 150px;
height: 100px;
}

#navigation-links a {
text-decoration: none;
color: #5cf79b;
}

.nav-collapse ul {
margin: 0;
padding: 10px;
display: block;
}

.nav-collapse li {
display: block;
padding: 10px;
text-align: center;
}



.js .nav-collapse {
clip: rect(0 0 0 0);
max-height: 0;
position: absolute;
display: block;
overflow: hidden;
zoom: 1;
}

.nav-collapse.opened {
max-height: 9999px;
}

.disable-pointer-events {
pointer-events: none !important;
}

.nav-toggle {
-webkit-tap-highlight-color: rgba(0,0,0,0);
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
color: #5cf79b;
text-decoration: none;
padding: 10px;
}

@media screen and (min-width: 40em) {
.js .nav-collapse {
position: relative;
}
.js .nav-collapse.closed {
max-height: none;
}
.nav-toggle {
display: none;
}

#navigation-links ul {
list-style: none;
float: right;

}

#navigation-links li {
display: inline;

}

}

最佳答案

您必须将 float 添加到容器和 display 菜单元素作为 inline-block

var navigation = responsiveNav(".nav-collapse", {
insert: "before"
});
/*! responsive-nav.js 1.0.32 by @viljamis */

#navigation-container {
background-color: #fff;
}

#nav-logo img {

width: 150px;
height: 100px;
}

#navigation-links a {
text-decoration: none;
color: #5cf79b;
}

.nav-collapse ul {
margin: 0;
padding: 10px;
display: block;
}

.nav-collapse li {
display: block;
padding: 10px;
text-align: center;
}



.js .nav-collapse {
clip: rect(0 0 0 0);
max-height: 0;
position: absolute;
display: block;
overflow: hidden;
zoom: 1;
}

.nav-collapse.opened {
max-height: 9999px;
}

.disable-pointer-events {
pointer-events: none !important;
}

.nav-toggle {
-webkit-tap-highlight-color: rgba(0,0,0,0);
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
color: #5cf79b;
text-decoration: none;
padding: 10px;
}

@media screen and (min-width: 40em) {
.js .nav-collapse {
position: relative;
}
.js .nav-collapse.closed {
max-height: none;
}
.nav-toggle {
display: none;
}

#navigation-links ul {
list-style: none;
float: right;

}

#navigation-links li {
display: inline;

}

}

#nav-logo { float: left; }
#navigation-links { float: right; }
#navigation-links ul li { display: inline-block; }
<header>
<div id="navigation-container">
<div id="nav-logo">
<a href="/"><img src="images/lvc-logo.png"></a>
</div>
<nav class="nav-collapse" id="navigation-links">
<ul>
<li><a href="/about">ABOUT</a></li>
<li><a href="/events">EVENTS</a></li>
<li><a href="/media">MEDIA</a></li>
</ul>
</nav>
</div>
</header>

关于javascript - 难以使用响应式导航插件排列我的导航链接和 Logo ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26476257/

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