在带有下拉菜单的网站上工作(没有Bootstrap)。
存在下拉菜单扩展到屏幕外的问题。查找了一些有类似问题的人,他们建议使用right / left属性,但是我似乎无法正常工作。
想法是当用户单击fa-language元素时,使div中的两个lis作为下拉菜单下降。有什么建议吗?
谢谢
body {
margin: 0;
padding: 0;
overflow-x: hidden;
overflow-y: hidden;
font-family: 'Cabin Condensed', sans-serif;
}
a {
text-decoration: none;
color: #B0BDC9;
}
#navbar {
padding: 1.25%;
background: #2F3236;
font-family: 'Fjalla One', sans-serif;
}
#navbar li {
display: inline;
padding: 15px;
}
.navbar-right {
float: right;
color: #B0BDC9;
}
.dropdown {
float: right;
overflow: hidden;
}
.dropdown-container {
display: none;
position: absolute;
color: #B0BDC9;
background-color: #2F3236;
min-width: 160px;
z-index: 1;
}
.dropdown-container ul {
display: block;
left: auto;
right: 0;
margin-right: -10px;
}
.dropdown-container ul li {
float: none;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
left: auto;
right: ;
}
.dropdown:hover .dropdown-container {
display: block;
}
.content {
margin: 0 auto;
margin-top: 75px;
width: 80%;
font-size: 1.2em;
color: #2F3236;
}
<link rel="stylesheet" type="text/css" href="personal_website.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<div id="navbar">
<li><a href="home.html">Home</a></li>
<li><a href="about_me.html">About Me</a></li>
<li><a href="interests.html">Interests</a></li>
<li><a href="publications.html">Publications</a></li>
<li><a href="contact.html">Contact</a></li>
<div class="navbar-right">
<li><a href="" target="_blank"><i class="fab fa-linkedin"></i></a></li>
<li><a href="" target="_blank"><i class="fab fa-twitter"></i></a></li>
<div class="dropdown">
<li><a href=""><i class="fas fa-language"></i></a></li>
<div class="dropdown-container">
<ul>
<li>English</li>
<li>Spanish</li>
</ul>
</div>
</div>
</div>
</div>
<div>
<h2 class="home-text">Text</h2>
</div>