我正在使用http://responsive-nav.com/插件来创建导航栏,但遇到链接和徽标水平排列的问题。我目前正试图将我的链接浮动到右侧,但它们仍然出现在我的图像下方的某个级别。有更好的方法吗?
桌面图片:
移动图片:
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;
}
}
答案 0 :(得分:0)
您必须将浮动添加到容器中,并将显示菜单元素添加为inline-block
。
var navigation = responsiveNav(".nav-collapse", {
insert: "before"
});
&#13;
/*! 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; }
&#13;
<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>
&#13;