我的菜单左侧有徽标,然后是旁边的链接,然后是右侧的下拉链接..但是末尾的下拉链接拒绝向右浮动。
logo ----链接链接链接------------------ dropdownlink
#main {
position: fixed;
width: 100%;
padding-top: 0px;
height: 60px;
font-size: 12px;
text-transform: uppercase;
background-color: #000;
z-index: 30;
}
#main a {
text-decoration: none;
}
.logo {
display: block;
margin-top: 10px;
height: 40px;
width: auto;
float: left;
}
.nav {
display: flex;
max-width: 1600px;
}
.right, .left{
display: inline-block;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
width: auto;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 22px 16px;
text-decoration: none;
float: left;
}
li a:hover {
background-color: #000;
}
.dropbtn {
background-color: #000;
margin-top: 10px;
color: #f0f0ee;
padding-top: 12px;
padding-bottom: 20px;
border: none;
cursor: pointer;
min-width: 100px;
text-transform: uppercase;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f0f0ee;
min-width: 185px;
right: 0px;
}
.dropdown-content a {
color: #000;
padding: 13px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: #e8e8e7;
}
.dropdown:hover .dropdown-content {
display: block;
float: left;
}
.dropdown:hover .dropbtn {
background-color: #f0f0ee;
color: #000;
}

<header id="main">
<div class="container-fluid">
<div class="nav">
<img src="images/logo.png" class="logo">
<ul class="left">
<li><a href="#link">link</a></li>
<li><a href="#link">link</a></li>
<li><a href="#link">link</a></li>
<li><a href="#link">link</a></li>
<li><a href="#link">link</a></li>
</ul>
<div class="right">
<div class="dropdown">
<button class="dropbtn">link <span class="caret"></span></button>
<div class="dropdown-content">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</div>
</div>
</div>
</div>
</header>
&#13;
答案 0 :(得分:0)
使用recursive
和right: 0
属性
position:absolute
.right {
position: absolute;
right: 0;
}
&#13;
#main {
position: fixed;
width: 100%;
padding-top: 0px;
height: 60px;
font-size: 12px;
text-transform: uppercase;
background-color: #000;
z-index: 30;
}
#main a {
text-decoration: none;
}
.logo {
display: block;
margin-top: 10px;
height: 40px;
width: auto;
float: left;
}
.right {
position: absolute;
right: 0;
}
.nav {
display: flex;
max-width: 1600px;
}
.right, .left{
display: inline-block;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
width: auto;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 22px 16px;
text-decoration: none;
float: left;
}
li a:hover {
background-color: #000;
}
.dropbtn {
background-color: #000;
margin-top: 10px;
color: #f0f0ee;
padding-top: 12px;
padding-bottom: 20px;
border: none;
cursor: pointer;
min-width: 100px;
text-transform: uppercase;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f0f0ee;
min-width: 185px;
right: 0px;
}
.dropdown-content a {
color: #000;
padding: 13px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: #e8e8e7;
}
.dropdown:hover .dropdown-content {
display: block;
float: left;
}
.dropdown:hover .dropbtn {
background-color: #f0f0ee;
color: #000;
}
&#13;